Android Question Can Intent based Alarm triggers my B4A activity?

omo

Active Member
Licensed User
Longtime User
Intent based alarm looks so consistent though with many glaring limitations. Based on google developer documentation, it seems programmers can manipulate it beyond its simple below demonstration:
B4X:
usage SetAlarm(18,17,Array As Int(2,3,4,5,6))    
Sub SetAlarm(Hour As Int, Minutes As Int, days As List)
    'manifest: AddPermission(com.android.alarm.permission.SET_ALARM)
    Dim i As Intent
    i.Initialize("android.intent.action.SET_ALARM", "")
    i.PutExtra("android.intent.extra.alarm.HOUR", Hour) 'to make it long running, hour + (day's hour equivalent)
    i.PutExtra("android.intent.extra.alarm.MINUTES", Minutes)
    i.PutExtra("android.intent.extra.alarm.DAYS", days)
    i.PutExtra("android.intent.extra.alarm.SKIP_UI", false)
    StartActivity(i)
    Log("alarm set")
End Sub
How can it be used to startactivity in b4a when alarm triggers? And how can phone.getSettings("next_alarm_formatted") be used in b4a to take next set alarm?
 
Last edited:

omo

Active Member
Licensed User
Longtime User
It is not possible. You need to use StartServiceAtExact.
Ok, thank you, Noted! It means I misinterpreted what Google meant here on receiving result:
Starting an activity
An Activity represents a single screen in an app. You can start a new instance of an Activity by passing an Intent to startActivity(). The Intent describes the activity to start and carries any necessary data. If you want to receive a result from the activity when it finishes, call startActivityForResult(). Your activity receives the result as a separate Intent object in your activity's onActivityResult() callback. @ https://developer.android.com/guide...ilters.html#q=android.intent.action.SET_ALARM

Yes, I have been using startserviceAt and foreground issue, my problem has always been on long schedule. When it starts at boot, to continue service is always where issue is. But one day if I can't resolve the issue, I will raise thread on that.
Thanks
 
Upvote 0
Top