Halim Halim - 20 days ago 8
Android Question

NEXT_ALARM_FORMATTED is deprecated

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

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);
    am.getNextAlarmClock();
    Log.d("Nextalarm",  am.getNextAlarmClock().toString());
    } catch (NoSuchMethodError e) {
        e.printStackTrace();
    }
Comments