[FREE] Alarm Extension

After having published a first extension and after what was commented by the leading users, about what had to change in the extension, I published it again with the recommended changes.

The extension now complies with the nomeclature instructions indicated in

I also try to adapt it to what is indicated in

  • Is it novel? Has your type of extension been done before by other extension developers. Do we really need it again? What is different/unique about it, when compared with the other similar extensions?

Although there is already an alarm extension (that I know of), this is paid, and the one I publish is free and also adds the source code for it.

  • Can the features or methods of the extension be completed with the built-in blocks and components of AppInventor? If so, there is any real need for an extension to do the same thing. There may be exceptions to this rule, where the compilation of the blocks is long and complex, and can be replaced with a simple method. A good example of this might be Saj's List Bubble Sort & Shuffle Methods 29 method (blocks) and Hossein's List Utils 21 (extension)

The extension only does what cannot be done with the App Inventor components, so the .aia file that accompanies it is almost as important as the extension.

What does the extension do?

  • Create exact alarms in time.
  • Delete alarms already created.
  • Guarantees permissions for Android versions 14 or higher
  • Notifies us when an alarm has occurred
  • We can choose when the alarm occurs, open the application or present us with a notification
  • You can open the device's default alarm sound and close it.
  • Alarms recover when you turn off or restart the device

Special configuration for Xiaomi devices

What to do with the .aia file

  • An alarm manager is created, creating a database with the alarms created or deleted.
  • Create simple alarms (time specified in seconds)
  • Create alarms at a given time and date
  • Create snooze alarms with a given hour and minutes and a day of the week
  • Every time the activity starts, all pending alarms are regenerated

I now explain the different blocks of the extension



Create an exact alarm at the indicated time, the "delay" must be specified in milliseconds and the "request" is a number that identifies the alarm.



Delete an alarm, with the "request" that we have previously assigned to it.

CheckPermission (boolean)


For Android versions 14 or higher, check that the SCHEDULE_EXACT_ALARM permission is granted

StartAlarmMusic and StopAlarmMusic (void)


You can open the device's default alarm sound and close it.

AlarmNow (boolean)


Indicates that the alarm has occurred

NotificationTitle (String)


You can assign a title to the alarm notification

OpenScreen (boolean)


If the value is true, when the alarm occurs, the activity will be opened, if false, a notification will be opened

In future posts I will detail and explain the .aia file

es.mariosoft.Alarm.aix (19,0 KB)

Alarmar.aia (124,6 KB)

AlarmSource.zip.txt (5,5 KB)

Un Saludo


Thanks for your extension Mario. It seems the aia needs to be compiled to work. I didn't know that at first. When I create an alarm, I can't dismiss it using your example code I imagine how will be explained. I will continue to explore Alarm Extension. It will make several of my apps more interesting. :wink:

I appreciate all your work. This keeps getting better. :smile:

When the alarm rings, just click on the screen and the alarm turns off.

Aia file tutorial (part 1)

What does the app do?

For the app to work you have to compile it, it does not work in the companion

  • We create Alarms (simple, date or repeat)
  • We manage alarms (when they occur they are automatically deleted from the database, we can also delete an alarm directly)
  • When an alarm occurs, if we have selected "OpenScreen" as true, a screen will open with the image of a clock and the alarm time. Clicking on the image will close this screen and stop the alarm audio.
  • When an alarm occurs, if we have selected "OpenScreen" as false, a notification will open with the date and time of the alarm, and with a message "Alarm (Click to finish)", clicking on the notification will open the activity and The alarm audio will stop.
  • Every time we create or delete an alarm, it will present the result in a Listview
  • You can set infinite alarms.

The two main components in the application are a TinyDB (which will manage the alarm database) and a Clock (which will help us with the calculations of dates and milliseconds)

The app will manage the alarms mainly every time it is started, so although the alarm notification is through the notification, once you click on it, the app will open (otherwise the app would not be able to stop. alarm sound)

We detail the different types of alarms


The argument we pass is millis (milliseconds)

  • We create a local variable "time" where we add the milliseconds that we pass as the argument plus the milliseconds that the system has at that moment.

  • We create an alarm with "delay" indicated in the variable "time" and as "request" also indicated in the variable "time"

  • In the TinyDB "DbAlarms.StoreValue" as a tag we indicate "time" and as ValueToStore we indicate a blank string (the reason will be explained later)

  • We present the database through the "AlarmDatabase" function (which will be explained later) in a ListView.


The parameters are (year, month, day, hour, minutes) all of them are numbers

It works in the same way as SimpleAlarm, the only difference is that we transform the given date into milliseconds through the clock component in the following way:


The parameters are (hour, minute and day) all three are numbers and day is managed as follows (Sunday = 1, Monday = 2.....Saturday = 7)

what we create is an alarm for a specific day of the week for a given hour and minute

Like all of them, the operation is very similar to SimpleAlarm, but with some differentiating characteristics.

To calculate the milliseconds we will use the "CalcDay" and "Time" functions that will transform the indicated parameters into milliseconds (these two functions use the clock plugin and I detail them below)

Once we have the milliseconds, the only difference is that in the TinyDB "DbAlarms.StoreValue" as a tag we indicate "millis" and as ValueToStore we indicate the parameter day (this will differentiate the alarms that are repetitive from those that are simple)


1 Like

Aia file tutorial (part 2)


Every time we start the activity because an alarm has occurred, it is verified that the last one is a repetition alarm, in this case we generate a new repetition alarm, seven days after the current day


Clears all alarms in the database whose delay is less than the current time (in milliseconds)


  • We clean past alarms
  • We go through the database "DbAlarmas.GetTags"
  • We check if it is a repeat alarm or not
  • We add the alarm in date format "dd/MM/yyyy HH:mm:ss" to a Lists
  • If the alarm is a repeat alarm, we also indicate it in the List with the day it repeats
  • We present the list in a ListView


Applies on Screen1.Initialize


  • We check if our Android is 14 or higher, if it complies with the SCHEDULE_EXACT_ALARM permissions, if so, a dialog will open to accept the permission.
  • Regenerates all active alarms
  • If an alarm has occurred and we have activated open the activity:
    • Opens a screen with the image of an alarm clock and alarm time
    • We start the alarm audio
    • We restore the alarm if it repeats seven days later
  • If an alarm has occurred and we have activated open the notification:
    • We stop the alarm audio
    • We restore the alarm if it repeats seven days later
  • We show the database in a ListView

Repeat alarms for several days

For this we use the Custom List Picker extension since app inventor does not allow multiple selection with its components.

For each selected day it creates a repeat alarm

For Xiaomi devices to be able to open the activity you must apply the following configuration

A new aia is included by mistake in the previous one

Alarmar.aia (124,5 KB)

Un saludo


How does the alarm stop when it starts playing?

I surely have choose the notification option

try this aia

Un saludo

I tried it but once the music starts playing in: Create an alarm it doesn't stop with anything even though I chose to delete it after it started playing.


Ok I found the solution, I put a stop button on right after the button : Repeat Alarm

If you want the alarm music to not stop when you press the notification and when you press the "Stop" button, within the "Start" procedure, delete the block that I indicated.


Is there a way to have the alarm stay active even when we close the app so that it beeps for a reminder we set?

If you do not use the "StopAlarmMusic" block, the alarm will sound continuously unless Android closes the service that manages the alarm music

this extension can work in second plane when you minimize the app?. if is yes. how block can i use for make that?

Alarms by definition always work in the background, if you put the CreateAlarm block in your application, it will sound even if the app is closed

You have the examples in posts 1, 4 and 5 of this topic

Is there a way to create a repeating alarm from Monday to Friday, but one that goes off every other week?

It could be done, modifying the days to be added as indicated in the image

You can also replace the AddDays block with AddWeeks, as indicated in the following image

millis, it would be a local variable, not a global one

Un saludo

1 Like

Can recurring alarms be entered more than once per day?

Can they work even after the device is turned off at night the next day after it is turned on?

Yes, it is possible to set more alarms in one day.
But if the device is restarted or closed in the evening and after opening in the morning, the alarms did not sound.

Instead of adding days or weeks as in the example in the previous post, we can add hours or minutes


At the moment the extension does not work correctly to recover alarms when the device is restarted or turned off

I haven't tested your extension yet, but it's actually an important aspect of an alarm that it doesn't need to be reset after restarting the device. @Taifun's AlarmManager extension does it (if I remember correctly).

1 Like