Humphrey
New Member
Hello to the forum,
I'm trying to read the next alarm time from the Android clock.
Here I found: Phone.GetSettings("next_alarm_formatted"), but since API 21 this function was deprecated. AlarmManager.getNextAlarmClock() should be used for API >= 21.
So my code is
When I run this code on my Samsung A6, the read Alarm time is always off by 5 minutes:
Alarm set to: 6:00
Alarm read: 5:55:01
On stackoverflow I found, that this is a bug of the Samsung clock app.
The app SleepClock from Allessandro71 shows the same problem on my phone.
Does anyone have a solution for that problem?
Humphrey
I'm trying to read the next alarm time from the Android clock.
Here I found: Phone.GetSettings("next_alarm_formatted"), but since API 21 this function was deprecated. AlarmManager.getNextAlarmClock() should be used for API >= 21.
So my code is
B4X:
Dim AlarmManager As JavaObject
Dim AlarmClockInfo As JavaObject
Dim rf As Reflector
Dim Context As JavaObject
Context=rf.GetContext
AlarmManager.InitializeStatic("android.app.AlarmManager")
AlarmClockInfo.InitializeStatic("android.app.AlarmManager.AlarmClockInfo")
AlarmManager = Context.RunMethod("getSystemService",Array As Object("alarm"))
AlarmClockInfo = AlarmManager.RunMethod("getNextAlarmClock", Null)
If AlarmClockInfo.IsInitialized Then
Dim Alarm As Long = AlarmClockInfo.RunMethod("getTriggerTime", Null)
TLabel.Text = DateTime.Time(Alarm)
End If
When I run this code on my Samsung A6, the read Alarm time is always off by 5 minutes:
Alarm set to: 6:00
Alarm read: 5:55:01
On stackoverflow I found, that this is a bug of the Samsung clock app.
The app SleepClock from Allessandro71 shows the same problem on my phone.
Does anyone have a solution for that problem?
Humphrey
Last edited: