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);
    }

  • 相关阅读:
    清除右键图形属性--图形选项
    Hibernate整合Struts2时报错
    shell基础篇(十)shell脚本的包含
    shell基础篇(九)函数
    浅谈sql的字符分割
    shell基础(八)-循环语句
    shell基础(七)-条件语句
    vue ---- Object的一些常用的方法
    vuex的应用和解决的实际问题
    webpack2代码分割
  • 原文地址:https://www.cnblogs.com/muhuacat/p/5258662.html
Copyright © 2011-2022 走看看