0

I want to detect if any otherapp going to draw over my activity, I tried with this Answer but no sucesss, can any body help me get notification when activity got obscured by any other view like face book chat head etc.

Jitendra Prajapati
  • 1,002
  • 1
  • 10
  • 33

1 Answers1

0

onPause() and onUserLeaveHint() can be used to check as per your requirements. Lets understand the concelpts.
onPause() gets called as part of the activity lifecycle when an activity is going into the background, but has not (yet) been killed. The counterpart to onResume().
Now question comes, this can happen when user press home or lock button, to handle this scanario. In this onUserLeaveHint() helps us to decide to if onPause() has been called because of user of some other app.
onUserLeaveHint() gets called as part of the activity lifecycle when an activity is about to go into the background as the result of user choice. For example, when the user presses the Home key, onUserLeaveHint() will be called, but when an incoming phone call causes the in-call Activity to be automatically brought to the foreground, onUserLeaveHint() will not be called on the activity being interrupted. In cases when it is invoked, this method is called right before the activity's onPause() callback.

For more information documentation can be read for onPause() and onUserLeaveHint() on developer website.

Hope this helps you.

Ankit Kumar
  • 3,663
  • 2
  • 26
  • 38