Battery checker reminding you to unplug when fully charged

This example uses the battery manager extension and itoo extension (Version 4) 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 3)

  1. 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.
    1

  1. in the background

How to setup the itoo extension?

  1. set the source of the player component to play a fanfare
  2. register the battery changed event of the battery extension
  3. register the after speaking event of the text to speech component
  4. 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.
  5. after that in the after speaking event of the text to speech component a fanfare will be played.

Screenshot of the user interface

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 13.

Source file Version 3
batterychecker.aia (185.6 KB)

Taifun

6 Likes

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.


It seemed to have fixed for me when I replaced TinyDB with Fetch and Store property blocks.

batterychecker(2).aia (181.5 KB)

You may check it once.

3 Likes

Thank you, I now updated the example in the first post

EDIT: A nice to have feature for the FetchProperty method would be a valueIfNameNotThere socket similar to TinyDB...

Taifun

2 Likes

@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 author of itoo is @Kumaraswamy

1 Like

Oops you're right, it wasn't just @Taifun who created it, but also @Kumaraswamy I apologize

1 Like

I now updated the example project to use the new FetchProperty method from the itoo extension Version 4
Unbenannt
Thank you @Kumaraswamy

Taifun

1 Like

Hello Taifun, this is your App Battery checker modify with Bluetooth BLE to work with ESP32 or Arduino with BLE

Inside the comment of the Initialize Global variable
ReadCommentForArduinoMain is the arduino program

With this App I charge my celular fone at 80% !

BatteryCheckerBLE_V1_a_2024-10-24.aia (361.1 KB)

Tks for Itoo !

2 Likes