[PAID] ⏰ Alarm Manager Extension with Notification or Autostart

Hey Taifun,

For the moment i just wanted to confirm the notification was working, which is why it is set for "now".

I have used Melon notification before, but i paid for the alarm manager a while back and figured this was a better fit.

After i have the notifcations working, i will be parsing through a list of timestamps to create the alarms.

But i havn't been able to get the notification to work so far.

Please explain why you want to do this in the background

Taifun

this app is to serve push notifications for a game that i play.
its a web browser based game, and doesn't offer push notifications natively.

So the goal of this app is to read the persons api response, and create notifications based on it.
The only thing provided by the api though is a timestamp of when the thing was started. i have to do the math to figure out when it will end.

i want this happening in the background on its own. So that the person always recieves the notifications. And additionally, the app simply references the itoo information that i save when processing the data. That way the data is always up to date, and is updating on a regular interval (which will be 5 minutes once i confirm that the background process is actually happening, and then set to a custom number by the user later after that.)

Then i just plug the timestamp into the alarm manager as an instant, and bang. push notification.

thats kind of the basic over view, let me know if you need more detail.

For short time intervalls (below 15 minutes) my suggestion is to use itoo together with a clock and the melon notification extension

If you like to continue using the alarmmanager extension and start an alarm via itoo as you are trying to doi it from your latest screenshot, you will have to fix your blocks like this:

In your procedure background _procedure there are 3 things missing: 1) the argument x

  • For the main background procedure, you need to include an argument "x".
  1. a statement

evaluate but ignore result TaifunAlarmManager1

  • A component does not get created until you touch any of its block

and 3) as you are using the web component to get some data from the api, you also should register a Web1 GotText event and create a corresponding event handler for rhat

See again the itoo documentation Open Source • Background Tasks: Itoo 🚀

Also in your test project don't use a clock to start the same alarm every 10 seconds again amd again, start it only once and be patient until the notification gets diplayed

For your test project you only have to ask for post notification permission and optionally schedule exact alarm permission

Fir debugging add Notifier LogInfo methods into your blocks and use logcat to check

Taifun

Maybe i misunderstood the alarm manager then.
For some reason i thought that it was supposed to replace the melon notification one?

is that incorrect?

Both extensions are used for different purposes, the only thing they have incommon is to send notifications

For the alarmmanager extension see also here App Inventor Extensions: Alarm Manager | Pura Vida Apps

For the MelonNotification extension see here 🔔 MelonNotification • Various styled notifications + Itoo

Taifun

to follow up.

most of what you explained here i have already. with the exception of the "x" value. which i have now added.

However. My issue is that i cannot get the alarm manager to post a notification at all.
after your suggestion about the "now" instant, i've added 30 seconds to it in the hopes that it would come through. But no luck so far.

To clarify. I have used the melon notifications, but it wasn't working from the background, which i suspect was because i was missing that "x" argument.

would still love if you would explain where i'm going wrong with the notifications from the alarm manager though.
Screenshot_40

I've put it into a manual button for the moment for testing. But i'm not getting the notification.

And i have looked through your examples several times... im sorry to say i am just failing to notice where my mistake is. if you need more blocks let me know :slight_smile:

What about trying my simple test project from the download folder?

From your screenshot it looks like you forgot to ask for post notification permission. Also use event Started to see, if the alarm has been set correctly... Btw. an index in App Inventor starts with 1, so I would use id = 1 instead of 0...

Then close the app and wait for the notification
EDIT: use the close application method for that. Remember, if you do not close the app and the app is still running at alarm time, then event AfterAlarm gets triggered...

Default is inexact alarms, so be a bit patient until you get the notification or ask additionally for schedule exact alarm permission

Note : Google recommends to use exact alarms wisely to reduce battery consumption. See also Use cases that might not require exact alarms. If you decide to use exact alarms, then the user needs to grant the SCHEDULE_EXACT_ALARM permission, see method AskForScheduleExactAlarmPermission

Btw. which device and Android version are you using for your tests?
Taifun

I'll try to address each part in the same order your presented it.

at the time of this post i haven't tried the test project yet. But I'll add that to my list today when i get a chance to sit.

Screenshot_41
I am asking for all the permissions, because i was unsure at the time if one of the other permissions was needed for the notification to post.
And the itoo process is starting (the notification is posting in the top bar). You addressed it earlier, and i think i fixed the process by adding the "x argument". But again havn't sat down to test it. Was a busy day yesterday.

I've fixed the index you mentioned, and will note that for later. My brain always says 0 for lists xD

And I'm using the "exact alarms" i think, unless there is an additional step after asking for the permission?

My current device for testing is my personal device, as this is the device i had planned to mainly use the app on.

It is a Galaxy fold 6. running Android 15

Yes, this would make things so much easier... you could see how to use the extension without wasting your and others time

Taifun

i had a few questions regarding this extension.

  1. is the "open above lockscreen feature" limited only to alarms(can only be triggered by alarms), or can that be triggered by a stimulant, say when bytes/strings are received by a BLE module?
  2. i believe that feature also brings the app to the foreground if im not wrong?

Currently only the alarmmanager extension and the sms receiver extension are able to do this

Currently not
EDIT: the use of this feature also is restricted by Google... for details see here Behavior changes: Apps targeting Android 14 or higher  |  Android Developers

Yes exactly

Taifun

thats not going to be a problem as im not going to release the product to the public anyway:3



im trying to trigger an alarm using itoo and ble and it works, but not in a way i expect it to work. instead of anything appearing on the lockscreen, i get only a notification with the title and text. i created another screen for lockscreen but it doesnt appear. i tried to follow the lockscreen app as much as i could, and the lockscreen app works perfectly fine, but this doesnt. i dont understand where the issue is. (even if the alarm activates because of ble received, the alarm still should perform as expected right?) all permissions required have been enabled as well.
is it because itoo is interfering with the app with the createprocess block?
ALSO: in recent xiaomi mobile phones, theres an additional show in lockscreen option that needs to be enabled by opening app settings. (advice)

UPDATE: you need to have the screen name of the lockscreen as "LockScreen" case sensitive if you want the lockscreen to appear.

Exactly! You got it. Congratulations !
Taifun

image
this query is with reference to the last line of the image, "in case...asap"

  1. if i put the instant to call clock1.now, will the alarm activate just after the button is pressed?
    if yes, then it doesnt work somehow for me{i created an apk of the lockscreen example file, and tweaked only that function a bit},
    and if no, then how does it work, and what does that sentence entail?
  2. if i want to trigger an alarm as soon as the button is pressed{button.click or idk}, how do i do so?

No

For short time intervalls (below 15 minutes) my suggestion is to use itoo together with a clock and the melon notification extension

If you use the alarmmanager it will take some seconds until the alarm activates

As a test try 1 minute, see aldo the example projects..

Taifun

Yes I could do it, but then I lose the functionality of the screen that appears above the lockscreen.

I see, but why? Is it the limitation of the extension?

Ok, I see

It is the underlying alarmmanager API

To solve the issue I think I could add some logic to not use the alarmmanager api in this case and trigger the alarm directly... I will do some experiments when I find some time...

Taifun

1 Like

that would help me greatly really.

please do
thank you
yns

I was thinking about it again... In your latest screenshot you click the Start button and your idea is to set an immediate alarm to open the app above the lockscreen... this does not make much sense like this, because your app already is running, isn't it?

Please describe your use case more in detail... are you trying to open the app above the lockscreen from the background using itoo together with the alarmmanager extension?

Taifun