Use appropriate AlarmManager methods for different API levels

This commit is contained in:
Doug Keen 2016-10-28 07:07:01 -07:00
parent dd854d0243
commit d77d80e39e

View File

@ -6,6 +6,7 @@ import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.os.Build;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.annotation.ColorInt; import android.support.annotation.ColorInt;
@ -595,7 +596,13 @@ public class Departure implements Parcelable, Comparable<Departure> {
long alarmTime = getAlarmClockTime(); long alarmTime = getAlarmClockTime();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, alarmTime, alarmIntent);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, alarmTime, alarmIntent);
} else {
alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime, alarmIntent); alarmManager.set(AlarmManager.RTC_WAKEUP, alarmTime, alarmIntent);
}
if (Log.isLoggable(Constants.TAG, Log.VERBOSE)) if (Log.isLoggable(Constants.TAG, Log.VERBOSE))
Log.v(Constants.TAG, Log.v(Constants.TAG,