Code Monkey home page Code Monkey logo

Comments (3)

shifujun avatar shifujun commented on June 11, 2024 1

这个问题只和Activity栈有关。Shadow在这个问题上特别简单,没有任何特殊处理。所以你需要关注的点就是PluginDefaultProxyActivity 等插件在宿主中的壳子Activity在manifest中声明的各种属性,比如singleTask等。对于系统来说,它只能看看是宿主启动了这个壳子Activity,即使相同的壳子配对了不同的插件activity。

查这个问题时你应该注意下切到后台前后Activity栈中的对象是否一致,也可能是重建的。还应该关注activity manager系统日志。另外我没什么见过launcher出现在栈里的印象。

没有代码就只能猜到这了。

from shadow.

LeonWu6 avatar LeonWu6 commented on June 11, 2024

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.

itxiaox avatar itxiaox commented on June 11, 2024

我也碰到类似问题,宿主Activity通过shadow打开插件Activity后,关闭插件Activity,直接返回到桌面,并不是期望的返回到上个Activity, 即宿主Actvity; 经过实验发现比较奇怪的是,当我的插件apk时候一个简单的APK(demo.apk)的时候是符合预期的,能正常返回上个Activity, 但当我把插件apk换成实际复杂业务插件APK的时候就出现上面情况,有大佬碰到过类似情况吗

from shadow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.