I am extending Application class to work with some global variables that need context. I know there is onCreate() method in the Application class that gets called before any
You can override onDestroy() in the Activity which will be the last one closed in your app and check if it's finishing. In this case your code will not be invoked on a device rotation. But you should be aware that onDestroy() is not invoked when an app is closed through device home button.
@Override
public void onDestroy(){
super.onDestroy();
if(isFinishing()){
//do your stuff here
}
}