当调用 getBroadcast 方法时,PendingIntent 发送一个广播。
AlarmManager alarmManager = (AlarmManager)this.getSystemService(ALARM_SERVICE);
Intent alarmIntent = new Intent(Constants.ALARM_ACTION);
PendingIntent mPendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, 0);
alarmManager.set(AlarmManager.RTC_WAKEUP, getMidnight()
.getTimeInMillis(), mPendingIntent);
我希望仅在警报响起时发送广播,而不是在调用 getBroadcast 时发送,但警报需要挂起的意图。有任何想法吗?