简体   繁体   中英

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. There is an example provided in the API documentation that I have linked to.

服务AlarmManager是您要寻找的,取决于您要执行的操作。

Use Android Services .You can use the following methods:-

  1. To call a Service which doesnt return any value back use - startService()
  2. To call a Service which return back values use - bindService()

Its good to be cautious when using any Sensors to run in the background as it might eat up you battery fast

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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