rtc 关机闹钟1 app层
2016-03-09 16:22
309 查看
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);
}
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);
}
相关文章推荐
- android中Invalidate和postInvalidate的区别
- GitHub Top 100的Android开源库
- GitHub Top 100的Android开源库
- GitHub Top 100的Android开源库
- Xcode插件 - iOS开发者最好的助手
- iOS本地通知
- ApplicationContextAware获取上下文bean
- iOS 基于Base64加密
- 160309iOS 浮点数显示的问题。
- 关于app
- atomic和nonatomic
- Android 自定义控件之打造流布局实现热门搜索标签
- 【Android】录音机
- 【转载】Android数据存储之SQLite
- app每月签到功能简单实现
- unity选择关卡的跑马灯效果
- Android设置里面默认存储器选项(default write disk)的实现
- iOS安装CocoaPods的终端命令
- iOS 【iOS-NSString的常用方法】
- Android MimeType的用法和几种类型