I am a beginner in Android App Development. I am trying to implement IntentService to run a process in the background when the user taps on the 'Start Service' button in main activity. The process is small, and usually finishes off right after few seconds of tapping the button. But that small process has to be run periodically, even after the app closes. Here is the code:
protected void onHandleIntent(Intent intent)
{
Log.i(TAG, "The service has now started");
//getting the source code of a html link
Log.i(TAG,"Task has been completed");
}
If I keep the Main Activity opened during the IntentService process, I get both the messages in the Log Cat. But if I close the app right after pressing the 'Start Service' button in Main Activity, I get only the first message i.e. 'The service has now started'. Does this mean that the process doesn't finish if I close the app? Why is this happening? What should I do to overcome this problem?
According to IntentService docs, there is no link between your service and the application main thread.
I think you aren't getting the log in LogCat because application closes. But the service are logging without your application tag.