Reputation: 891
I'm trying to learn how to develop Android and I'm currently following this tutorial on the activities lifecycle: https://developer.android.com/training/basics/activity-lifecycle/pausing.html
I created a very simple code to check the triggering of the onPause()
and onResume()
functions, e.g. for onPause()
I just wrote the following in one of my activities (and I did the same kind of stuff for the onResume()
function):
@Override
protected void onPause() {
super.onPause();
Toast.makeText(this, "ON PAUSE", Toast.LENGTH_LONG).show();
Log.i("STATUS_ON_PAUSE", "ON PAUSE");
}
When I start/stop the activity or when I switch from one activity to another I do see the corresponding Toasts and logs. But I don't see anything when I overlay a facebook-messenger conversation over my activity. No Toast when opening the conversation (I would have expected to see "ON PAUSE"), no Toast when giving the focus back to my application.
I tried to inspect the log-files on a broader level (my device) but I'm still not good enough to really understand what goes on there (way too much information). So, my question is: how come my activity is not paused/resumed when I give/remove focus to a chat-head? Thanks!
Upvotes: 0
Views: 261
Reputation: 5566
The simplest answer would be:
Messenger is adding a view to a Window instead of starting a new activity.
This is why Messenger needs SYSTEM_ALERT_WINDOW permission and you can see that when you see it's details: "draw over other apps" permission.
You can see THIS ARTICLE
Upvotes: 2