Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between activity visible liftime and foreground lifetime?

We know that the android activity cycle has multiple phases.

between onStart() and onStop() is called the visible lifetime between onResume() and onPause() is called the foreground lifetime

What are the the key difference between them? Please give examples if possible.

like image 413
Bader Avatar asked Dec 05 '22 17:12

Bader


2 Answers

If I display an Activity on the screen and the user is interacting with it, it is both in the foreground and visible.

If I start another Activity, which is transparent and shows a dialog box over the previous Activity, then the new Activity (the dialog box) is in the foreground and the old Activity is not in the foreground but still visible.

like image 69
Jon O Avatar answered May 18 '23 15:05

Jon O


between onStart() and onStop() called visible lifetime that mean that the activity is visible either entire activity or partially visible and the user can see it on the screen and interacte with

between onResume() and onPause() called foreground lifetime that your activity is full visible and running and have full focus .

UPDATE

partially visible for example if another activity come in front of the current one and it only display a dialog and a transparent background . the user can see that activity but cant interact with it

like image 41
confucius Avatar answered May 18 '23 17:05

confucius