I need to log an event only when the application as a whole has lost focus (such as an incoming call or the home key).
What is the best way to tell an Activity has been paused or stopped from an external event rather than another activity within the same app?
Thanks
when your activity stops you can check if your app is still on top in the
onStop()method:This method queries all running tasks first. In general the task which has focus is on top of the stack. Check if this task belongs to your package.