android - 使用安卓 :process =":remote" recreates android Application object

标签 android service process

我在我的应用程序中使用 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/

相关文章:

java - 我可以使用表面对象在 Android 中制作显示对象吗?

android - 相对布局,Textview 不显示

android - 使用 jackson 解析 Realm 模型

android - 来自服务的持久性 android 通知

Android 服务位置监听器未激活

android - 在单独的进程android中启动服务

ruby-on-rails - 计算机科学家的 Web 开发

java - native : Could not initialize Tesseract API with language=eng

c++ - 多次加载同一个dll

Linux 进程生成/创建触发器