DoubleP90
DoubleP90

Reputation: 1249

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?

Upvotes: 0

Views: 476

Answers (3)

viswanath patimalla
viswanath patimalla

Reputation: 218

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

Upvotes: 0

ndsmyter
ndsmyter

Reputation: 6605

Services or AlarmManager is what you are looking for I think, depends on what you want to do..

Upvotes: 0

Chinmay Kanchi
Chinmay Kanchi

Reputation: 65843

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.

Upvotes: 1

Related Questions