I’m trying to distinguish if an activity is destroyed then restarted vs. when it’s started via standard startActivity call. What’s the best way to distinguish this? I need to track a counter, and the counter should not be incremented when the app has been destroyed and restarted. I tried using putExtra(String, String), but the value returned is the same regardless.
I’m trying to distinguish if an activity is destroyed then restarted vs. when it’s
Share
You could try using a flag isSavedInstanceState. Set this flag to false in onResume. Set this flag to true in onSaveInstanceState. Check this flag in onStop.
This will increment your counter on a hard kill. You could check the bundle in onCreate for a null bundle if you want, but I have not fully tested that logic.