简体   繁体   English

Android Lollipop上的持久应用程序

[英]Persistent App on Android Lollipop

In my Android manifest, I have flagged my application as "persistent", so that it automatically restarts if it crashes, is less likely to be killed by the system, etc. I know that normal applications cannot use this setting, but I am working on a custom ROM, and I load my application into the priv-app folder, and so I am able to use it. 在我的Android清单中,我将我的应用程序标记为“持久”,以便在崩溃时自动重新启动,不太可能被系统杀死等等。我知道正常的应用程序无法使用此设置,但我正在工作在自定义ROM上,我将我的应用程序加载到priv-app文件夹中,因此我可以使用它。

This works perfectly well on pre-Lollipop phones. 这对前Lollipop手机非常有效。 However, when I load my APK onto an Android 5 phone, the "persistent" setting is no longer honoured. 但是,当我将APK加载到Android 5手机上时,“持久”设置不再受到尊重。 I can use 'dumpsys activity' to verify that my app is persistent on Android 4.4.4, but not on Android 5.0. 我可以使用'dumpsys activity'来验证我的应用程序在Android 4.4.4上是持久的,但在Android 5.0上却没有。

Is there some additional requirement for persistence in Android 5? 在Android 5中是否还有一些额外的持久性要求? I see that some system-supplied apps are still persistent, so it's not as if it's completely impossible. 我看到一些系统提供的应用程序仍然是持久的,所以它不是完全不可能的。 Thanks. 谢谢。

Turns out I misunderstood the nature of the problem. 结果我误解了问题的本质。 The real problem was that I hadn't given the apk the selinux context permissions. 真正的问题是我没有给apk提供selinux上下文权限。 I used chcon to copy the context from another file in priv-app and that sorted it out. 我使用chcon从priv-app中的另一个文件复制上下文并将其排序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM