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

Since the app has to be open (active) at the time of clocking in and clocking out (taking timestamps), I don't see any problems implementing such apps with AI2 (or Kodular, Niotron, ...).

Try this simple app (initially just for one day and one break / pause):

1 Like

Of course, it should be "Clock in" :wink:
I changed / updated it.

Incidentally, this has nothing to do with my extension.

Thanks again for the answer, it helped. But I've now switched to Kodular because I found it easier. There is an item called ListView Image and Text. A new item is created with every click on the stamp button, which also works perfectly. The problem is, every time the screen is restarted, the list view is emptied because it is not saved. I've searched the internet but haven't found anything on how to save a ListView. Can you please help again :laughing:? Thank you and have a nice day.

If using Kodular, then ask on the Kodular community.

Does my test app (APK) work for you (also after restarting the app)?

1 Like

Yes, it worked perfectly.

I asked here because I saw in the Kodular Community that Anke had answered a few topics.

1 Like

There is good reason, 1 - we then know which distribution you are using, 2. AI2 and Kodular are different in many ways, what works on one does not necessarily work on the other. This is why it is best to ask on the correct community.

4 Likes

We should move this into a new topic, because it has nothing to do with my extension anymore.

2 Likes

really Thank You very Much :heart_eyes: :hearts:

1 Like

The Android Developer link pretty much describes the distinction between onPause and onStop.
Essentially onPause is not killable by the OS, but onStop is.
So do anything important in onPause, as onStop may not fully execute....

Did you check it yourself?

I had tested it extensively on dozens of devices at the time, and as I already pointed out, after on Pause (at least on non-tablets) onStop is always executed. As you can see in my tests, I was able to store something with onPause as well as with onStop. However, it may be that this behaves differently on tablets (as Evan Patton said; I haven't tested it).

No, I did not test it myself, but I do believe what I read on the Android Developer page (which is linked to right at the top of your extension description)

I'm NOT saying onStop never happens straight after onPause, but the docs say it is possible that onStop may not reach the end of execution.
The OS may destroy the app before it concludes - this may not always be the case, and hence why it appears to be OK to use onStop.

BUT as they do document it, I'd consider that it is risky to reliably use onStop for important things like saving configs, but onPause will not get aborted by the OS so that's where it should take place.
A distinct but important difference I'd say :slight_smile:

Cheers, Ray

But what I will add is your extension has proven invaluable to solve a problem I had with the Paho MQTT client extension entering a world of networking hurt when the phone shut shop.
All was good when open and running, but once the app was put to sleep it would then have problems once awakened.

So now I force the connection closed in onPause, then reopen in onResume - far more stable.

So thank you very much for providing this extension.

1 Like

As I said before, this may be relevant for tablets.