I created an application that always worked before Android 6.0. I think this is a Doze function that does not allow my alarm to fire.
I use sharedpreferences to handle the parameters:
//ENABLE NIGHT MODE TIMER int sHour = blockerTimerPreferences.getInt("sHour", 00); int sMinute = blockerTimerPreferences.getInt("sMinute", 00); Calendar sTime = Calendar.getInstance(); sTime.set(Calendar.HOUR_OF_DAY, sHour); sTime.set(Calendar.MINUTE, sMinute); Intent enableTimer = new Intent(context, CallReceiver.class); enableTimer.putExtra("activate", true); PendingIntent startingTimer = PendingIntent.getBroadcast(context, 11002233, enableTimer, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager sAlarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); sAlarm.setRepeating(AlarmManager.RTC_WAKEUP, sTime.getTimeInMillis(), AlarmManager.INTERVAL_DAY, startingTimer);
Any clue on what's wrong here?
This is a call blocking application. Thanks!
EDIT: I have 3 files (more, but ...), for example:
MainActivity (All code) CallReceiver (Broadcast that triggers the alarm again (reboot etc)) CallReceiverService (Handles the call / phone state)
android android-pendingintent alarmmanager android-alarms
FilipeOS
source share