Do you plan AI will work when hidden?

One of the things that make me stop develope my ideas is that AI doesn’t work when it’s not at main screen. (Well, sometimesit does for a while but when it’s left for some more hours it doesn’t).

Things like clock and its timer-off feature is one of this things.
Do you plan to make it work while hidden or i shouldn’t expect it?

There is no timeline for introducing background services to AppInventor 2.

Ok, thank you for clearyfing.

If the app is closed, nothing can be done from the app, also not " for a while".

There are many misconceptions about the term “background”. Background as used here means only that the app is not visible (eg after pressing the home button or after time-out / in sleep mode), but not closed. "Background tasks / services" means that an app can also execute somthing if the app is closed. That's is indeed not possible with AI2 & its clones (AB, Thunkable, Kodular, ...).

So show your blocks or post the aia.

Hey, thank you, if it is like you say it would be sufficient for me.

I had this problem in two cases. One case when i found it doesn’t work is when clock Timer off it should check what hour is it. When it is 23 the block ‘reset’ should be executed. And well - it didn’t. This block changes some labels/text boxes to blank, hide some parts of application and changes colors of some buttons.

Second case: I have created alarm (not that android one) and when user didn’t touch special button before certain hour the alarm started off (sounds were created by me and used by Player module). It works when application was visible and sometimes it works when hidden. So it should work, but didn’t.

As an attachment i provide two blocks to first case. Maybe i choose wrong blocks?

case 1 timer

Check this simple app:
testBackground.aia (12.4 KB)

Build the APK (should also work with Companion).
Enter the current minute + x or the current hour + x in the TextBox and test whether it also works in the background (after pressing the device home button or the power button - in sleep mode - or both).

1 Like

Thank you for your test. It seems that it works when i push the devices home button and even when i press home button and screen is off.

It doesn’t work when i press ‘back button’ on the phone (i also added Tiny DB block to TextBox1 to make app remember the minute i set but it still doesn’t work, even the scrren is on).

So to conclude app should work when the home button was pressed (and screen can be off). So i have to check why in my own app it didn’t, i must have done some mistake.
Big thanks Anke!

Of course, it cannot work if the back button is clicked, as the app will then close.

There is also a way to prevent that (leave the block empty):

1 Like

That’s awesome tip!!
So now, i could add to it another button called ‘close app’ with proper module under it if someone want to close app legally :slight_smile:

Please tell me one more thing, the 'x' in your sentence means 'press ok' or something else?

It was only for testing to add a value (e.g. 1) to the current minute or hour.
So if the current minute is e.g. 10, enter 11 in the TextBox.

thank you Anke

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.