I wasn't exactly sure how to word this question, but I know it's a very simple one to answer. How can tell when the user is no longer on the activity I want the user to be on. For example, how do I know if the user has unexpectedly pressed HOME or if a phone call is received and interrupts the current activity?
You can check if your Activity has focus with this method:
hasWindowFocus()
If you want to capture when the user leaves the activity, you'd want implement this in your Activity:
protected void onPause() {
super.onPause();
// Code here...
}
Also there is more info about activity life cycle here: http://developer.android.com/reference/android/app/Activity.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With