Use the Activity’s isFinishing()
method.
@Override
protected void onDestroy() {
super.onDestroy();
if (isFinishing()) {
// do stuff
} else {
//It's an orientation change.
}
}
More Related Contents:
- Android activity life cycle – what are all these methods for?
- Android app out of memory issues – tried everything and still at a loss
- How to retrieve the dimensions of a view?
- How to check if an activity is the last one in the activity stack for an application?
- Android: Under what circumstances would a Dialog appearing cause onPause() to be called?
- Android Application Class Lifecycle
- android finish() method doesn’t clear app from memory
- onNewIntent() lifecycle and registered listeners
- How to test code built to save/restore Lifecycle of an Activity?
- Android Fragment onCreateView vs. onActivityCreated
- Android 11 Scoped storage permissions
- Using Build Flavors – Structuring source folders and build.gradle correctly
- How do I create a ListView with rounded corners in Android?
- Screen orientation lock
- How to hide status bar in Android
- How to disable past dates in Android date picker?
- Check if device is plugged in
- activeNetworkInfo.type is deprecated in API level 28
- One Activity and all other Fragments [closed]
- URLConnection or HTTPClient: Which offers better functionality and more efficiency?
- Android SAF (Storage Access FrameWork): Get particular file Uri from TreeUri
- Android Cursor with ORMLite to use in CursorAdapter
- Rotating an android VideoView
- camera2 captured picture – conversion from YUV_420_888 to NV21
- Android studio where is gradle.properties file?
- How to Lock Android App’s Orientation to Portrait in Phones and Landscape in Tablets?
- android popup menu text color (AppCompat)
- Using setImageDrawable dynamically to set image in an ImageView
- On Android, make a POST request with URL Encoded Form data without using UrlEncodedFormEntity
- Simulate killing of activity in emulator