zoukankan      html  css  js  c++  java
  • 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);
    }

  • 相关阅读:
    数据可视化——Matplotlib模块入门
    小甲鱼第23,24课后练习
    小甲鱼第28课课后练习
    小甲鱼第27课课后练习
    小甲鱼第25课课后练习
    小甲鱼第21课课后练习
    Java:泛型(一)
    决心考研之后
    Java:null
    树:哈夫曼编码解码及压缩存储
  • 原文地址:https://www.cnblogs.com/muhuacat/p/5258662.html
Copyright © 2011-2022 走看看