Android Question Start receiver at exact time / Why my code is not working ?

Armani

Member
Hello All,

I'm stuck since few days to receive an Intent if the app was closed before by user.

I start with @Erel post to understand "Start receiver at exact time" and I add notification with NB6 library example.

On my code:
- first page is to get Notification permission from user
- then on a second page, 3 buttons are to set a time duration 1Min / 10Min / 1Hour

I expect to get the Intent on ScheduleReceiver and then diplay a notification.

Code is working, if the app is not closed by user, but if the app is closed, then apparently I never receive the ident.....and never get the notification...?

Is that behavior normal ? is it an error in my code ?

I need to get a notifcation after a long period (few hours) and I need to get it even if user close the app.

How to do that ?

My code is attached


Many thanks for your help
 

Attachments

  • StartReceiverAtExact Notification.zip
    69.5 KB · Views: 88
Solution
For what it worth, I've tested your app on an Android 14 device. I ran it in release mode. Scheduled a 1 minute alarm and killed the app. The alarm did fire.

Assuming that you didn't do any mistake and ran the app in debug mode for example, then it should work on most devices. There are however devices where the intents will be discarded after the user kills the app.

Armani

Member
Yes exactly, swipe by user. Waiting duration to get Intent will be long, so user may probably kill the app.
In fact I need same behavior than Alarms application, you set wake up time, and even with app closed you get it.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
For what it worth, I've tested your app on an Android 14 device. I ran it in release mode. Scheduled a 1 minute alarm and killed the app. The alarm did fire.

Assuming that you didn't do any mistake and ran the app in debug mode for example, then it should work on most devices. There are however devices where the intents will be discarded after the user kills the app.
 
Upvote 0
Solution

f0raster0

Well-Known Member
Licensed User
Longtime User
I tested your App in Android 10, 13, 14 and it worked for me - I killed/swipe the App
 
Upvote 0

Armani

Member
Mant thanks to you @Erel and @f0raster0, thanks for your time and support.

I'm on Redmi Note 11, Android 13.
My tests were in Release mode (with logger?, I'll try to remove it, and test again).

AT least you confirm that it's supposed to work.

Many thanks again
 
Upvote 0

NikB4x

Member
Licensed User
Longtime User
HI,
tested on Motorola Edge 40 with Android 14 and works very well!
I terminated the app but still received the notification.
 
Upvote 0

Armani

Member
I do not really know what I did wrongly, but after deleting the app and proper re-install, it's working correctly...

Thanks again for your help and test
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…