I need to reset notification when user removes my app from background.So I need to have an event of remove app from background.
Please help me out. Suggestion appreciated. Thanks. Kind Regards.
I need to reset notification when user removes my app from background.So I need to have an event of remove app from background.
Please help me out. Suggestion appreciated. Thanks. Kind Regards.
Official android documentation
Activity.onDestroy()
The final call you receive before your activity is destroyed. This can happen either because the activity is finishing (someone called finish() on it, or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the isFinishing() method.
http://developer.android.com/reference/android/app/Activity.html#onDestroy()
Whenever an app is removed from background it's processID is changed.
Simply compare those pid(Process ID).
int oldProcessID = SettingsSharePref.readProcessID();
int newProcessID = android.os.Process.myPid();//getProcessID(mContext);/
if( oldProcessID != newProcessID ){
//if it killed or started as a new process...
SettingsSharePref.saveProcessID(newProcessID);
}
In the life cycle of android . you can find onDestroy() method, with the help of this you can have a broadcast receiver or service based on your requirement. Hope you got a solution