持续性服务 [英] Persistent service

查看:179
本文介绍了持续性服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道一些民族的观点是,你不应该创建持久的服务。

I know that some peoples view is that you should not create persistent services.

但对于我们这些希望增加我们的知识,一个人如何去在理论上建立一个?

But for those of us that want to increase our knowledge, how does one go about creating one in theory?

我一直在玩弄,并注意到使用服务<一href="http://developer.android.com/reference/android/app/Service.html#startForeground%28int,%20android.app.Notification%29"相对=nofollow> startForeground 在低内存情况下杀死。

I have been playing around, and noticed that services that use startForeground are killed in low memory situations.

我已经看到了,现在去precated,权限 PERSISTENT_ACTIVITY ,但是这并没有做太多。

I have seen a, now deprecated, permission PERSISTENT_ACTIVITY, but that didn't do much.

那么,什么是秘密?

推荐答案

您只能使你的服务持续性,如果您正在开发的系统的应用程序。这些服务将基本取消killable,并标记为在亚行外壳dumpsys活动命令的输出PERS。这不是很好的记录,所以我做了一个快速的持续服务的Andr​​oid写了< /a>...hopefully它会帮助一些人出来。

You can only make your service persistent if you are developing system apps. These services will be basically un-killable, and are labeled as "PERS" in the output of the "adb shell dumpsys activity" command. It's not very well documented, so I did a quick write-up on Persistent services in Android...hopefully it will help some people out.

但对于非系统的应用程序,startForeground是最好的选择。

But for non-system apps, startForeground is your best option.

这篇关于持续性服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆