我制作了一个在 Android 6.0 之前一直有效的应用程序。我认为这是打瞌睡功能,它不允许我的闹钟触发。
我使用 sharedpreferences 来处理选项:
//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);
这里有什么问题的任何线索?
这是一个阻止呼叫的应用程序。谢谢!
编辑: 我有 3 个文件(更多但是...),例如:
MainActivity (All code)
CallReceiver (Broadcast that triggers the alarm again (reboot etc))
CallReceiverService (Handles the call / phone state)