Extension - Activity Lifecycle of an app (onPause → onStop → onResume)

I checked it on Android 14 & 15. No problem at all.

1 Like

@Anke

Have you tested in a compiled APK?

The app is not in the background (but still visible). Press the Home button of your device and then come back. Then all 3 events (Pause, Stop, Resume) are triggered, in this (chronological) order.


See also here: Extension - Activity Lifecycle of an app (onPause → onStop → onResume) - #7 by Taifun and here: Extension - Activity Lifecycle of an app (onPause → onStop → onResume) - #8 by ewpatton

...or use this method:

grafik

yes this is compiled app not connected to live testing


@Anke

What he showed in the first video, I think it should trigger OnPause

Use three 3 labels (Label1, Label2, Label3, one for each event) and try again.

Use the Notifier LogInfo method together with Logcat to find out, that the OnPause event gets triggered

What you see in the video is a snapshot of the last screen which was active before moving to the back

Taifun

1 Like

okay will try

Try this one: activityLifecircle.aia (13.0 KB)

What happens to lifecycle events when reopening the same screen?
i.e. If I use open another screen "Screen1" to refresh the screen, what lifecycle events are triggered?

How about trying it out yourself?

1 Like

only the OnPause event is triggered. :slightly_smiling_face:

No. When the screen is reloaded, no event is triggered (neither OnResume nor OnPause nor OnStop).

i have checked , OnPause event is triggered.

Companion or APK? But it shouldn't be triggered at all.
Post your test aia.

i tested in apk. deleted that project. please wait i ll do it again.
test LifeCycle.aia (6.3 KB)

No, the fact that you see a pause for a few milliseconds is because closing the screen takes a few milliseconds, just short enough to trigger only Pause and not Stop. But that happens while closing the screen, not while reopening it.

Therefore, no events are triggered by reloading the screen.

1 Like