Home » Android » How to run android application in background

How to run android application in background

Posted by: admin June 15, 2020 Leave a comment


Possible Duplicate:
how to run application in background in android?

i am doing project using location manager if my location latitude and longitude equal to the same which is in database mobile profile should go to silent mode.so i need to keep on update my location using location manager.i did it .but if i close my app it’s not working.
but my app should be working even though i close my app.i tried with async task its working when i close the app but after i switch to loud mode manually it’s not changing to silent.i should also get notified when my app runs n background..please help.tks in advance

here is my code

How to&Answers:

You have coded in Activity, I suggest you to changed it to Android Service. A Service is a component which runs in the background, without interacting with the user.

Have a look at Vogella’s Service Example.

Just Convert your Activity code into Android Service and it will work in background without any GUI.