如何设置机器人服务的优先级? [英] How to set the priority of android service?
问题描述
有什么办法来设置的Android服务的优先级?我想破坏应用程序的主actvity后在后台运行的服务。因此,我从我的服务返回START_REDELIVERY_INTENT。但服务重新启动正在采取一定的时间(约1-3分钟)。我想立即重新启动该服务。有什么办法来设置的Android服务的优先级。
Is there any way to set the priority of android service? I want to run the service in background after destroying App's main actvity. So i am returning "START_REDELIVERY_INTENT" from my service. But restarting of service is taking some time (around 1-3 minutes). I want to restart the service instantly. Is there any way to set the priority of android service.
仅供参考,我创建使用startService服务,并通过intent.putExtra()传递一个对象。
FYI, I am creating service using startService and passing an object through intent.putExtra().
下面的快照取自设置/应用程序/我的Android设备,这表明应用程序正在重新启动......我的应用程序是实时的具体运行的应用程序,所以我要立即重新启动......
Below snapshot is taken from setting/apps/running apps by my android device, which shows that app is restarting... My app is real time specific, so i want to restart it instantly...
推荐答案
您无法控制服务的这种行为
因为这取决于操作系统和可用资源。然而,对于一个连续运行的后台服务,我建议你回到 START_STICKY
- 它试图尽最大努力重新运行该服务一旦其以任何理由破坏,由于
You cannot control this behavior of Service
as it depends on the OS and available resources. However, for a continuously running background service, I would suggest you to return START_STICKY
- which tries its best to re-run the service once its destroyed due to any reasons.
这篇关于如何设置机器人服务的优先级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!