1. when the user close the application forcefully
2. when Android it self destroy the Activity.
3. when user hits the back button
Unfortunately you can not distinguish between 1 and 2.
But you can do something when user clicks the back button since onPause() is called after onBackPressed(),
so you can put a flag in the onBackPressed(). That way you can distinguish how it landed here
onBackPressed() -> onPause() or
home button / multitask button -> onPause()