How to distinguish between orientation change and leaving application android

Use the Activity’s isFinishing() method.

@Override
  protected void onDestroy() {
    super.onDestroy();
    if (isFinishing()) {
      // do stuff
    } else { 
      //It's an orientation change.
    }
  }

Leave a Comment