Alarm Manager with Itoo

The aia file aims to create an alarm system based on a background system created with Itoo.

Reliability is maximum and it will always notify us exactly at the hour and minute marked as the alarm.

The app would manage the service, auto-starting when there are pending alarms and closing when there are no pending alarms in the database.

The application uses the following components


The aia consists of two parts:
1.- The Activity part
2.- The Service Part

1. In the activity part there are the following blocks


This procedure will start with Screen1.Initialize and what it does:

  • Create the shared variable "musicalarma" in which we will save the source of the player component.

  • Manage the shared variable "alarmanow" that is updated by the service every time an alarm occurs. From this variable, apart from closing it again as the block does, the activity could be told to do anything else.

  • Present the database of pending alarms in a Listview.


Start the service if it is no longer open, it is used when we create an alarm


It creates two types of alarm depending on what we indicate in the "Type" variable, one based on dates and another simple one based on seconds, for this:

  • We calculate the milliseconds of the created alarm based on a TimerPicker and a DatePicker (date type) or a Textbox (seconds type) and the clock component

  • We empty the data from the shared variable "listaalarmas" into a local variable "lista"

  • If the time of the created alarm is greater than the current time, it is added to the "lista" variable

-We order the list variable from most recent to least recent.

-We save the shared variable "listaalarmas" with the data of the local variable "lista"

-We present the database in the ListView

-If the service is not on, we turn it on.


  • We present the database saved in the variable in the ListView

The aia also allows you to delete an already established alarm by clicking on a record in the lisview that will open a dialog box.

2. In the Service part there are the following blocks


This block is called every time we start the service

-Register the Clock and Play components

-Start the clock

-It tells the play component what its source is through the shared variable "musicalarma"

-Register the clock Timer event through the data procedure


In this procedure we are going to tell the service what to do each time the Clock Timer event occurs.

-We start a local variable "lista" with the data from the shared variable "listaalarmas"

-We compare the current time in "yyyy/MM/dd HH:mm:ss" format with the data from the first record of the "lista" variable with the same format.

-If they match, an alarm is produced and the following actions are activated

  1. A notification is created with the title "Alarm (click to finish)" and in the subtitle the alarm data in "dd/MM/yyyy HH:mm" format.
    This notification has the characteristic that clicking on it opens the main activity (Screen1).
    2.Set the shared variable "alarmanow" to true
    3.The Player component starts playing
    4.Delete the first record of the local variable "lista", since this alarm has already passed
    5.Save the shared variable "listaalarmas" with the data of the local variable "lista"

-The service checks that the main activity has set the shared variable "alarmanow" to false, in this case it stops the player and cancels the notification

-If the service verifies that the shared variable "listaalarmas" is an empty list, it turns off the Timer and closes the service

It is important in the compiled application that if the phone is a Xiaomi or a Samsung it is necessary to configure the battery saving as "No Restrictions"

AlarmaItoo.aia (163.6 KB)

all the best


Thank you @Mario1 for the tutorial, as we can see you know how to work with Itoo, you created an impressive example!

However there are 2 major disadvantages of your solution compared to a real alarmmanager like [PAID] ⏰ Alarm Manager Extension with Notification or Autostart :

  1. Your solution needs to display a persistent notification in the notification bar as it uses forground service. A real alarmmanager runs without that.

  2. Your solution drains the battery heavily... as you set it up, your process checks each second, if the alarm time occurred to then display a notification... even if you do this check only each minute or each hour, you need a process running to check the time. Actually this is like abusing the Android system. A real alarmmanager gets triggered from the Android operation system at the alarm time and then displays the notifiation.

You have shown what could be done using Itoo, but in the end it is not a recommended solution to use in an app.

Did you let your example running a few days so see, if it is still running or if Android finally decides to terminate this heavy process in the background?


Thank you for your response Taifun

It is clear that this is just a tutorial on how itoo works, the alarm thing is an example, I have already published an itoo tutorial with the Pedometer component and another creating a streaming radio station player that never cuts out.

To set an alarm, as you say, an extension that uses is better, but it could work perfectly for a short timer.

I have tested the compiled application with alarms for up to three days and it has not failed (the best thing about the app is the reliability in the exact time of the alarm), I have a Xiaomi phone so I have had to put the energy saving system energy as "Unrestricted"

Regarding battery consumption, it may increase battery consumption by 3%, more or less like any other background service.

As I said before, for an alarm app it is better to use your extension or any that uses

all the best

1 Like

As indicated by Taifun

Indeed, if a new alarm is checked every second, it would be very costly for the system.

I have modified this aspect and now the Timer has an interval equal to the time to the next alarm, which could be 10 seconds or 3 days, so the system is released and there is no problem of forcing it

If the next alarm is in 5 hours and 10 minutes, that would be the Timer interval

For this I have made the following modifications in the aia

alarm procedure

As can be seen when the service starts, the Timer has an interval equal to the time we have in the database to which we add the system time (all in milliseconds)

data procedure

When the Timer verifies that there is a new alarm, it does everything indicated in the first post and also sets its interval to 1 second, in order to receive the response of the activity for which the alarm has already arrived.

Once the service receives this response, if there is a new alarm, it sets the timer interval to the time left for the new alarm. If there were no more alarms, it would turn off the service.

Un Saludo

AlarmaItooV2.aia (164,4 KB)


First of all I congratulate you on your alarm manager using the Itoo service. But I ask you a curiosity of mine; How did you make the TimePicker prettier than the traditional one?

He used Theme "Device default" instead of "Classic".

1 Like

@Mario1 , how can I check your other tutorials?

1 Like

The strange thing is that now, even though I keep trying to change the TimePicker theme from Classic to default device; I am irremediably left with the classic theme

The strange thing is that now, even though I keep trying to change the TimePicker theme from Classic to default device; I am irremediably left with the classic theme :upside_down_face:

Reload the browser.