在自己的进程中运行 Activity 的每个实例?
我有大量第三方本机代码,正在使用 NDK 在 Android 上运行。此代码包含全局变量,因此仅支持每个进程一个会话。 (除非 Android 有某种神奇的方法可以将共享库的多个实例加载到同一进程中。)
我必须能够同时运行多个 Activity。这意味着每个 Activity 必须在不同的进程中运行。有谁知道我可以用什么方法来做到这一点?
请注意,进程亲和力在这里没有帮助,这允许我指定一个命名进程,单个 Activity 类的所有实例都在其中运行。我在这里想要的是有一个 Activity 类的多个实例,每个实例都在自己的进程中运行。
我吃姜饼(或以上);我愿意考虑任何犯规的黑客来使这项工作成功......
(另外:冒着听起来暴躁的风险,请不要向我解释为什么这是一个坏主意,我应该做点什么否则,告诉我我的外部要求是错误的并不能帮助我满足我的外部要求......)
I have a big chunk of third-party native code that I'm running on Android using the NDK. This code contains global variables, and as such only supports a single session per process. (Unless Android has some magic way of loading multiple instances of a shared library into the same process.)
I have to be able to run multiple Activities concurrently. This means that each Activity has to run in a different process. Does anyone know any way I can do this?
Note that process affinity doesn't help here, is this allows me to specify a single named process that all instances of a single Activity class run inside. What I want here is to have multiple instances of an Activity class each running in their own process.
I'm on Gingerbread (or above); I'm willing to consider any foul hack to make this work...
(Also: at the risk of sounding tetchy, please do not explain to me why this is a bad idea and I should do something else. Telling me that my external requirements are wrong isn't helping me meet my external requirements...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在清单文件中为您希望在不同进程中启动的活动设置 android:taskAffinity 和 android:process 。
You have to set both, android:taskAffinity and android:process in your manifest file for activities you wish launch in different processes.
这个如何
检查文档。这应该有效。
How about this
check the docs. This should work.