We build an Android Launcher and have some strange behaviour with onDestroy() and finish(). According to the docs and this post, isFinishing()
should only be true if finish() is called on the Activity. However, while finish() is never called on the MainActivity, isFinishing() is true in the MainActivity's onDestroy() method.
The first time after creating the MainActivity, when a user installs or uninstalls an app through the Play Store, the onDestroy() of the MainActivity is called after exiting the Play Store. This only happens the first time, after that the onResume() method is called as expected, without recreating the MainActivity.
I'm checking whether isFinished() is called like this:
@Override
public void finish() {
// (Never called)
super.finish();
Log.i(TAG, "Finish called. " + isFinishing());
}
@Override
public void onStop() {
super.onStop();
// When opening the Play Store app, isFinishing is false here
Log.i(TAG, "onStop called. Finishing: " + isFinishing());
}
@Override
public void onDestroy() {
super.onDestroy();
// When exiting the Play Store app (opening our Launcher), isFinishing is true the first time,
// after that onDestroy isn't called anymore.
Log.i(TAG, "onDestroy called. Finishing: " + isFinishing());
}
Does anyone know why onDestroy is called the first time after installing / uninstalling an app? Thanks!