我已经定义了我的Android闹钟和BroadcastReceiver
,如下所示。我的希望是我希望警报在两分钟之后以及随后的每15分钟发出一次。这似乎没有发生。这是为什么?
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + 2);
PendingIntent pi = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(getApplicationContext(), DailyNotificationReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager am = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, pi);
public class DailyNotificationReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("received", "received");
}
}
答案 0 :(得分:1)
正如评论中所讨论的,BroadcastReceiver
未注册。
请在BroadcastReceiver
manifest