I am new to android development and so please apologize if my question is very simple.
I am trying to build an android app which is a location based app, through which users (say Person A) can track another users (say Person B) location continuously.
In app settings, we have an option called ‘Force stop’. So from the above case, anytime Person B can kill my running app using this ‘Force stop’, so that his location will not be properly monitored by Person A.
I need to avoid this. I have to continuously monitor Person B’s location and make him to avoid killing my app using ‘Force Stop’. how can I achieve this?
-
Is there any way in android to call a particular method (so that I can have some alert code to person A) when Person B clicks the ‘Force Stop’ button.
-
Or is there any way through which, even if Person B stops my app, I can alert the user and restart my app again!
Suggestions please.
Thank You.
There’s no way that user B’s app can notify user A that user B clicked “Force Stop”, because “Force Stop” brings everything to a halt immediately.
However, user A can infer it if user A’s app is expecting regular updates from user B. If user A’s app pings user B every minute, and after 1 minute user B’s app does not respond, then user A’s app can assume that user B’s app is “dead”. This is probably a better way to do it, anyway. Other things besides “Force Stop” can cause user B’s app to be unavailable: user B turns off the device, user B can no longer communicate with user A, Android considers user B’s app to be low priority and kills it, user B app crashes because of a bug, etc.