Comments (3)
这个问题只和Activity栈有关。Shadow在这个问题上特别简单,没有任何特殊处理。所以你需要关注的点就是PluginDefaultProxyActivity 等插件在宿主中的壳子Activity在manifest中声明的各种属性,比如singleTask等。对于系统来说,它只能看看是宿主启动了这个壳子Activity,即使相同的壳子配对了不同的插件activity。
查这个问题时你应该注意下切到后台前后Activity栈中的对象是否一致,也可能是重建的。还应该关注activity manager系统日志。另外我没什么见过launcher出现在栈里的印象。
没有代码就只能猜到这了。
from shadow.
Hi shifujun @shifujun
感谢您的回复!
这个问题的原因我找到了。
我在一个APK(后面称为ParentAPK)中通过 startActivity() 的方式,启动了我的 com.oplus.em 宿主 APP的 MainActivity,但我没有加 Intent.FLAG_ACTIVITY_NEW_TASK 这个 flag,使得 com.oplus.em/.MainActivity 这个宿主APP的 activity 是在 ParentAPK 的task 里面,如下:
Task{7219a54 #92 type=standard A=1000:com.oplus.parentApk U=0 visible=true visibleRequested=true mode=fullscreen translucent=false sz=3}
mLastPausedActivity: ActivityRecord{aee6e1 u0 com.oplus.em/.pluginhelper.PluginLoadActivity t-1 f}}
mLastNonFullscreenBounds=Rect(283, 690 - 797, 1770)
isSleeping=false
* Hist #2: ActivityRecord{3e483b3 u0 com.oplus.em/.MainActivity t92}
packageName=com.oplus.em processName=com.oplus.em
而我的 com.oplus.em 的插件 Activity 是在自己的 com.oplus.em 的 task 里面。如下:
* Task{9bd32b5 #95 type=standard A=1000:com.oplus.em U=0 visible=true visibleRequested=true mode=fullscreen translucent=true sz=1}
mLastNonFullscreenBounds=Rect(283, 690 - 797, 1770)
isSleeping=false
topResumedActivity=ActivityRecord{4c706c0 u0 com.oplus.em /.runtime.PluginDefaultProxyActivity t95}
* Hist #0: ActivityRecord{4c706c0 u0 com.oplus.em /.runtime.PluginDefaultProxyActivity t95}
packageName=com.oplus.em processName=com.oplus.em :plugin
所以,宿主APP 和插件 APP是在不同的两个 APP task 中。
所以,当插件APP从前台切换到后台,再切回前台时,插件 task和 宿主task 中间就插入了 launcher UI 的 task。
解决方法就是在 parentApk 启动我的 com.oplus.em 宿主APP 的 MainActivity 时,加上一个 flag:
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
这样,com.oplus.em 的宿主和插件就在相同的 com.oplus.em 的task 中了,中间不会再插入其他 task。
from shadow.
我也碰到类似问题,宿主Activity通过shadow打开插件Activity后,关闭插件Activity,直接返回到桌面,并不是期望的返回到上个Activity, 即宿主Actvity; 经过实验发现比较奇怪的是,当我的插件apk时候一个简单的APK(demo.apk)的时候是符合预期的,能正常返回上个Activity, 但当我把插件apk换成实际复杂业务插件APK的时候就出现上面情况,有大佬碰到过类似情况吗
from shadow.
Related Issues (20)
- 请教下:运行test-none-dynamic-host模块,启动的插件还是在宿主进程的问题。 HOT 4
- 插件manager中的view如果有ProgressBar,但是宿主不显示ProgressBar HOT 4
- 插件apk没有用到四大组件,有必要弄成多进程吗? HOT 2
- 宿主获取插件Fragment可显示,宿主跳转到插件FragmenActivity报错,请指教 HOT 2
- 执行sample-app报错,要怎么解决? HOT 2
- 插件内可以调用qq分享吗?
- androidx.profileinstaller.ProfileVerifier安全校验失败? HOT 1
- 请问 normalImplementation 是只有Shadow才有的吗? HOT 2
- 宿主启动多插件 HOT 1
- Caused by: java.lang.ClassCastException: androidx.appcompat.widget.ContentFrameLayout cannot be cast to androidx.appcompat.widget.ContentFrameLayout HOT 2
- java.lang.VerifyError: Rejecting class com.demo.pluginmanager.UpPluginManager that attempts to sub-type erroneous class com.demo.pluginmanager.FastPluginManager (declaration of 'com.demo.pluginmanager.UpPluginManager' appears in /data/user/0/com.demo/files/upshadowmanager-release-1.3.4.2023070701.apk) HOT 3
- Caused by: java.lang.UnsupportedOperationException: Can't convert to color state list: type=0x1 at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2718) at android.content.res.Resources.loadColorStateList(Resources.java:2699) at android.content.res.TypedArray.getColorStateList(TypedArray.java:485) at android.widget.TextView.<init>(TextView.java:746) at android.widget.TextView.<init>(TextView.java:671) at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:102) at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:97)
- shadow经过线上上亿用户的检验,想咨询下
- 希望添加 jni 调用的演示示例 HOT 2
- sample-host release模式多项测试失败 HOT 2
- 卸载插件时遇到无法删除文件的问题 HOT 2
- none-dynamic场景使用so HOT 4
- 启动插件时,会报上下文NullPointerException HOT 2
- 报错,找不到DelegateProvider
- 宿主更新插件,要重启宿主后插件才生效 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shadow.