Android Question Get next alarm from Android Clock App


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
    Dim AlarmManager As JavaObject
    Dim AlarmClockInfo As JavaObject
    Dim rf As Reflector
    Dim Context As JavaObject

    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?

Last edited:


Licensed User
Longtime User
If the code works correctly on non-samsung phones, then you may be able to simply detect if the phone is made by samsung, and if so, then compensate for the 5 mins on just those devices.

Here's some sample code to determine if the device is made by samsung:

Dim p As Phone
If p.Manufacturer.ToLowerCase = "samsung" Then
    Log("This is a Samsung device.")
    ' Your code for Samsung devices here
    Log("This is not a Samsung device.")
    ' Your code for other devices here
End If
Upvote 0


New Member
Thanks for your replies, JohnC and Alessandro71.
If it's not on all Samsung phones, it's hard to find out if my function is working correctly or not.:(
So it's not possible to compensate for the 5 minutes.

But today I found out, that my function is also reading the next calendar alarm. This, by the way, with the correct time.
I have a reminder in my calendar for tomorrow 9:30, but no alarm clock alarm set.
My function is returning 9:30 of tomorrow.
This is what also Alessandro71's App SleepClock returns.
@Alessandro71: Is this also only on my phone, or general on all phones?
Is it possible to read only alarm clock alarms?
Upvote 0


Well-Known Member
Licensed User
Longtime User
I'm also using Phone.GetSettings, since I never had the time to experiment with the new, non-deprecated, method
Upvote 0