rtc 关机闹钟1 app层
private static void enableAlertPowerOn(Context context, final Alarm alarm, final long atTimeInMillis) {
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.cancel(MyPendingIntent);
Log.d(TAG, "** setAlert id " + alarm.mId + " atTime " + atTimeInMillis);
// Intent intent = new Intent(ALARM_ALERT_ACTION);
// Intent intent = new Intent(context, SchedulePowerOff.class);
Intent intent = new Intent(context, com.borqs.schpwronoff.SchPwrOnReceiver.class);
// XXX: This is a slight hack to avoid an exception in the remote
// AlarmManagerService process. The AlarmManager adds extra data to
// this Intent which causes it to inflate. Since the remote process
// does not know about the Alarm class, it throws a
// ClassNotFoundException.
//
// To avoid this, we marshall the data ourselves and then parcel a plain
// byte[] array. The AlarmReceiver class knows to build the Alarm
// object from the byte[] array.
Parcel out = Parcel.obtain();
alarm.writeToParcel(out, 0);
out.setDataPosition(0);
intent.putExtra(ALARM_RAW_DATA, out.marshall());
PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
MyPendingIntent = sender;
am.set(5 , atTimeInMillis, sender);
Log.d(TAG, "Alarms.enableAlertPowerOn(): setAlert id " + alarm.mId + " atTime " + atTimeInMillis);
long now = System.currentTimeMillis();
// setStatusBarIcon(context, true);
Calendar c = Calendar.getInstance();
c.setTime(new java.util.Date(atTimeInMillis));
// String timeString = formatDayAndTime(context, c);
// saveNextAlarm(context, timeString);
}