Halim Halim - 1 year ago 182
Android Question


Since API 21 / Android 5.0

The field Settings.System.NEXT_ALARM_FORMATTED is deprecated

What is the alternative for doing this? I saw http://developer.android.com/reference/android/app/AlarmManager.html#getNextAlarmClock()
But I really don't know how to implement it.

Answer Source

You should upgrade android to api level 21 and your device also should be compatible with that, you can remove try..catch block also but it is better if in your manifest.xml android:minSdkVersion is less than 21.

try {
    AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
    Log.d("Nextalarm",  am.getNextAlarmClock().toString());
    } catch (NoSuchMethodError e) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download