I have to clear some application data after my application is finished running.As far as I know onDestroy()
may not be called. So I decided to check if isFinishing() == true
in onPause()
of the root activity to see whether this activity and other ones of my app are in the process of finishing. But I doubt if this activity:
<activity
android:name="com.test.AuthorizationActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
will be a root activity? And is this a correct way in general?
I think you need to rethink your design because it seems that it isFinishing
is true only when finish
is called on the activity and does not account for cases where the activity is destroyed because of low memory.
From the docs:
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.
For what you are suggesting you could possibly store the application's state data in static
variables, which will be cleared when your application process ends (when the last activity/ service is finished).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With