我在我的应用程序中使用 AIDL 服务。
我还想在另一个进程中运行它,所以我在 list 的服务声明中使用了 android:process=":remote"
。
我的问题是,当 :remote
进程启动时,它显然会重新创建 Application
对象。
我真的不这样做,因为我覆盖了应用程序对象并在 onCreate()
方法中调用了很多客户端内容。但是我希望服务代码与客户端驻留在同一个 apk 中。
我能做到吗? Application
对象是否总是在新进程启动时重新创建?
感谢您的帮助。谢谢!
最佳答案
I also want to run it another process
为什么?这会给用户增加什么值(value),以抵消额外的 RAM、CPU 和电池成本?很少有应用需要不止一个进程。
My problem is that when the ':remote' process starts it apparently recreates Application object
当然。每个进程都有自己的。
I really do not with that as I override application object and call lots of client stuff in the 'onCreate()' method
然后去掉 android:process=":remote"
。您的用户会感谢您。
Yet I want the service code to reside in the same apk with the client.
什么服务?
Is Application object always recreated when new process starts?
是的。
关于android - 使用安卓 :process =":remote" recreates android Application object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15545345/