这可能会有所帮助-------广泛的演员班------------------------- --
public class TimeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context ctx, Intent intent) {
Toast.makeText(ctx, "It's time to WAKE UP!!!!", Toast.LENGTH_SHORT).show();
}
}
----------------在Activity类中写这段代码-------------------------
PendingIntent sender = null;
Intent intent = null;
Calendar systemtime = Calendar.getInstance();
systemtime.setTime(new Date());
Calendar timeToTriggerAlarm = Calendar.getInstance();
timeToTriggerAlarm.set(Calendar.HOUR_OF_DAY, systemtime.get(Calendar.HOUR_OF_DAY));
timeToTriggerAlarm.set(Calendar.MINUTE, systemtime.get(Calendar.MINUTE));
timeToTriggerAlarm.set(Calendar.SECOND, 00);
intent = new Intent(this,TimeReceiver.class);
sender = PendingIntent.getBroadcast(this, 0, intent,PendingIntent.FLAG_ONE_SHOT);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, timeToTriggerAlarm.getTimeInMillis(), sender);
注意-打开您的清单文件并单击选项>添加>接收器>浏览>添加类名(这里是 TimeReceiver)