This example uses the battery manager extension and itoo extension (Version 4.5.0, custom extension with foregroundservice type: SpecialUse) to get a reminder to unplug the device when fully charged.
What does the example app provide?
You can configure the battery level (between 80 and 99%) at which you like to get a reminder. Then start the background process. In case the device is charging and the predefined battery level is reached, you will hear a voice saying "The battery is fully charged. Please unplug!" and a fanfare will be played. This will repeat until the device gets unplugged.
Screenshot of the blocks (Version 5)
user interface
The example uses the StoreProperty/FetchProperty methods from the Itoo extension to pass a value (here the battery level) from the user interface to the background process. Then the background process is created, which will be started also at boot time.
in procedure "run": let itoo know, that the batterymanager extension exists
in the battery changed event: if the battery is charging and reached the predefined level, then the text "The battery is fully charged. Please unplug!" will be spoken.
after that in the after speaking event of the text to speech component a fanfare will be played.
Note: Usually we would expect to get a permanent notification displayed while the background process is running in foreground mode. But starting from Android 13 we have to ask for notification permission, so if we do not ask for that permission, we do not get that annoying notification displayed.
Test
Tested on Samsung Galaxy A54 running Android 16.
Hi Taifun, TinyDB relies on SharedPreferences, this causes synchronization issues. That means when a value is updated from the App, it dosent nessasaly mean the changes will reflect in the background process.
To solve this issue, Itoo offers a Store/Read functionality similar to TinyDB to combat this issue.
@Taifun some time ago I purchased the very useful Alarm Manager app from you and I thought that this was the only way to launch an event in the background; instead now I discover that you created the itoo extension. So from now on, we could use this extension to use apps in the background. P.s: In fact, without this extension, Mit App Inventor was objectively very limiting, I congratulate you
The example has been updated using the latest itoo version 4.5.0 (custom extension using foregroundservice type SpecialUse) and tested successfully today targeting SDK36 on the test server