[英]Keep app running in background
i made an application which keep the screen awake, and it works fine until it gets killed by the system. 我制作了一个使屏幕保持清醒的应用程序,在它被系统杀死之前,它可以正常工作。 How can i keep my app running in background?
如何使我的应用程序在后台运行? I see a lot of apps that uses notifications to stay running and avoid being killed, but i don't know how to implement it.
我看到很多使用通知来保持运行并避免被杀死的应用程序,但是我不知道如何实现它。 Can someone help me achieve this?
有人可以帮助我实现这一目标吗?
You can use the Service API for this, specifically the startForeground(int, Notification) function call. 您可以为此使用Service API,特别是startForeground(int,Notification)函数调用。 There is an example provided in the API documentation that I have linked to.
我链接到的API文档中提供了一个示例。
服务或AlarmManager是您要寻找的,取决于您要执行的操作。
Use Android Services .You can use the following methods:- 使用Android 服务 。您可以使用以下方法:-
Its good to be cautious when using any Sensors to run in the background as it might eat up you battery fast 使用任何Sensor在后台运行时要格外小心,因为它可能会很快耗尽您的电池电量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.