Intent in2 = new Intent(context, ReminderService.class);
PendingIntent pendingIntent2 = PendingIntent.getBroadcast(context, 0, in2, 0);
AlarmManager alarmManager2 = (AlarmManager)context.getSystemService(context.ALARM_SERVICE);
alarmManager2.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (5 * 1000), 0, pendingIntent2);
和reminderservice.java包括下面的代碼這段代碼做了什麼?爲什麼我的鬧鐘沒有停止?
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Context context = getApplicationContext();
Intent in = new Intent(this, RemindBroadcastReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, in, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (5 * 1000), 1000, pendingIntent);
}
和我的鬧鐘使用的用戶Remindercycle功能,所以這就是爲什麼使用它的IM –
意思是說,你要定期觸發報警(反覆在一定的時間間隔)? –
意味着我想每天,每週,每月,每年重複我的警報。 –