Reputation: 651
I must to know if my Activity is displayed or not. I would to use the method onPause and onResume but I want to know also why the activity is in onPause.... There are 3 cases :
How can I do ? Thanks
EDIT : I resolved with this code :
ActivityManager activityManager = (ActivityManager)getContext(). .getSystemService(Context.ACTIVITY_SERVICE);
List<RunningTaskInfo> runningTasks = activityManager.getRunningTasks(Integer.MAX_VALUE));
Upvotes: 1
Views: 1091
Reputation: 132982
*1.* Activity in onPause because the display turn off and if any call appear :onPause()
called
*2.*Activity in onPause because the user have clicked the home button :onUserLeaveHint()
called before onPause()
if user press home button
*3.*When user press Back key :onUserInteraction()
called before onPause()
Upvotes: 4
Reputation: 4460
When You leave from one Activity to other Activity the activity from where you are leaving that activity onPause get called. If you want to experiment create all the function Inside the onStart call the other activity onPause of the First activity get called.
For more Information please go through by below link:
http://developer.android.com/guide/topics/fundamentals/activities.html
Upvotes: 0