Sometime we wish to track our user activity when user closed particular activity in app so we can follow this life cycle of Activity :
If you want to send status to your server when application closed or force quit then you should use override method onPause() because this method always guarantee to run if your app get closed or forcefully quit. Don't use onStop() because in case of force quit this method will not work. Don't use onDestroy() because this method will work when your activity will get destroyed.
@Override
public void onPause()
{
doSomething();
super.onPause();
}
You can set some api to update server in doSomething() method.
0 Comment(s)