android.app.AlarmManager.setWindow()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中android.app.AlarmManager.setWindow()方法的一些代码示例,展示了AlarmManager.setWindow()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AlarmManager.setWindow()方法的具体详情如下:
包路径:android.app.AlarmManager
类名称:AlarmManager
方法名:setWindow

AlarmManager.setWindow介绍

暂无

代码示例

代码示例来源:origin: commonsguy/cw-omnibus

private void schedule() {
  mgr.setWindow(AlarmManager.ELAPSED_REALTIME,
   SystemClock.elapsedRealtime()+PERIOD, WINDOW,
   getClass().getSimpleName(), this, null);
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = KITKAT)
public void setWindow_shouldRegisterAlarm_forApi19() {
 assertThat(shadowAlarmManager.getNextScheduledAlarm()).isNull();
 alarmManager.setWindow(AlarmManager.ELAPSED_REALTIME, 0, 1,
   PendingIntent.getActivity(activity, 0, new Intent(activity, activity.getClass()), 0));
 assertThat(shadowAlarmManager.getNextScheduledAlarm()).isNotNull();
}

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = N)
public void setWindow_shouldRegisterAlarm_forApi24() {
 assertThat(shadowAlarmManager.getNextScheduledAlarm()).isNull();
 OnAlarmListener listener = () -> {};
 alarmManager.setWindow(AlarmManager.ELAPSED_REALTIME, 0, 1, "tag", listener, null);
 assertThat(shadowAlarmManager.getNextScheduledAlarm()).isNotNull();
}

代码示例来源:origin: evernote/android-job

@Override
protected void plantOneOffInexact(JobRequest request, AlarmManager alarmManager, PendingIntent pendingIntent) {
  long currentTime = System.currentTimeMillis();
  long startMs = currentTime + Common.getStartMs(request);
  long lengthMs = Common.getEndMs(request) - Common.getStartMs(request);
  alarmManager.setWindow(AlarmManager.RTC, startMs, lengthMs, pendingIntent);
  mCat.d("Schedule alarm, %s, start %s, end %s", request,
      JobUtil.timeToString(Common.getStartMs(request)), JobUtil.timeToString(Common.getEndMs(request)));
}

代码示例来源:origin: evernote/android-job

@Override
  protected void plantOneOffFlexSupport(JobRequest request, AlarmManager alarmManager, PendingIntent pendingIntent) {
    long currentTime = System.currentTimeMillis();
    long startMs = currentTime + Common.getStartMsSupportFlex(request);
    long lengthMs = Common.getEndMsSupportFlex(request) - Common.getStartMsSupportFlex(request);

    alarmManager.setWindow(AlarmManager.RTC, startMs, lengthMs, pendingIntent);

    mCat.d("Scheduled repeating alarm (flex support), %s, start %s, end %s, flex %s", request,
        JobUtil.timeToString(Common.getStartMsSupportFlex(request)), JobUtil.timeToString(Common.getEndMsSupportFlex(request)),
        JobUtil.timeToString(request.getFlexMs()));
  }
}

代码示例来源:origin: Justson/DingDingHelper

public static void resetTiming(Context context, long timeInMillis, Intent intent) {
  AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
  PendingIntent sender = PendingIntent.getBroadcast(context, intent.getIntExtra("id", 0),
      intent, PendingIntent.FLAG_CANCEL_CURRENT);
  int interval = (int) intent.getLongExtra("intervalMillis", 0);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    am.setWindow(AlarmManager.RTC_WAKEUP, timeInMillis, interval, sender);
  }
}

代码示例来源:origin: Justson/DingDingHelper

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  am.setWindow(AlarmManager.RTC_WAKEUP, calMethod(week, calendar.getTimeInMillis()),
      intervalMillis, sender);
} else {

代码示例来源:origin: henrichg/PhoneProfilesPlus

@Override
protected void plantOneOffInexact(JobRequest request, AlarmManager alarmManager, PendingIntent pendingIntent) {
  long currentTime = System.currentTimeMillis();
  long startMs = currentTime + Common.getStartMs(request);
  long lengthMs = Common.getEndMs(request) - Common.getStartMs(request);
  alarmManager.setWindow(AlarmManager.RTC, startMs, lengthMs, pendingIntent);
  mCat.d("Schedule alarm, %s, start %s, end %s", request,
      JobUtil.timeToString(Common.getStartMs(request)), JobUtil.timeToString(Common.getEndMs(request)));
}

代码示例来源:origin: henrichg/PhoneProfilesPlus

@Override
  protected void plantOneOffFlexSupport(JobRequest request, AlarmManager alarmManager, PendingIntent pendingIntent) {
    long currentTime = System.currentTimeMillis();
    long startMs = currentTime + Common.getStartMsSupportFlex(request);
    long lengthMs = Common.getEndMsSupportFlex(request) - Common.getStartMsSupportFlex(request);

    alarmManager.setWindow(AlarmManager.RTC, startMs, lengthMs, pendingIntent);

    mCat.d("Scheduled repeating alarm (flex support), %s, start %s, end %s, flex %s", request,
        JobUtil.timeToString(Common.getStartMsSupportFlex(request)), JobUtil.timeToString(Common.getEndMsSupportFlex(request)),
        JobUtil.timeToString(request.getFlexMs()));
  }
}

相关文章