I moved some code to monitor LogCat into a service. First time for this for me. I read the tutorial.
I ONLY need this running while my app/process is running. It may not continue to be in the main activity, but some secondary activity, but so long as the process for this app is active (for any activity of it) I want my logcat monitor service to continue to run.
In the Activity_Create of the main/startup activity of the app I call StartService to start my service module.
It escapes me to find an appropriate place to call StopService to shut it down. I do NOT want to do it when the main activity is paused of course.
One thought that occurs to me is that this service is activated to work via an event each time there is logcat activity. Perhaps my service can check and see if the app is still running?? My questions:
1) Is there a way for a service module to see if my app process is still running?
2) Is there a way for a service module to end itself if the results of 1 is NO?
Maybe there is a better way to do this?
I ONLY need this running while my app/process is running. It may not continue to be in the main activity, but some secondary activity, but so long as the process for this app is active (for any activity of it) I want my logcat monitor service to continue to run.
In the Activity_Create of the main/startup activity of the app I call StartService to start my service module.
It escapes me to find an appropriate place to call StopService to shut it down. I do NOT want to do it when the main activity is paused of course.
One thought that occurs to me is that this service is activated to work via an event each time there is logcat activity. Perhaps my service can check and see if the app is still running?? My questions:
1) Is there a way for a service module to see if my app process is still running?
2) Is there a way for a service module to end itself if the results of 1 is NO?
Maybe there is a better way to do this?