本文整理汇总了Java中android.app.AlarmManager.INTERVAL_HALF_DAY属性的典型用法代码示例。如果您正苦于以下问题:Java AlarmManager.INTERVAL_HALF_DAY属性的具体用法?Java AlarmManager.INTERVAL_HALF_DAY怎么用?Java AlarmManager.INTERVAL_HALF_DAY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.app.AlarmManager
的用法示例。
在下文中一共展示了AlarmManager.INTERVAL_HALF_DAY属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intervalMillisForRecurringAlarm
private static long intervalMillisForRecurringAlarm(String intervalPref) {
int interval = Integer.parseInt(intervalPref);
switch (interval) {
case 0:
return 0; // special case for cancel
case 15:
return AlarmManager.INTERVAL_FIFTEEN_MINUTES;
case 30:
return AlarmManager.INTERVAL_HALF_HOUR;
case 1:
return AlarmManager.INTERVAL_HOUR;
case 12:
return AlarmManager.INTERVAL_HALF_DAY;
case 24:
return AlarmManager.INTERVAL_DAY;
default: // cases 2 and 6 (or any number of hours)
return interval * 3600000;
}
}
示例2: scheduleStartBlockchainService
public static void scheduleStartBlockchainService(final Context context) {
final Configuration config = new Configuration(PreferenceManager.getDefaultSharedPreferences(context),
context.getResources());
final long lastUsedAgo = config.getLastUsedAgo();
// apply some backoff
final long alarmInterval;
if (lastUsedAgo < Constants.LAST_USAGE_THRESHOLD_JUST_MS)
alarmInterval = AlarmManager.INTERVAL_FIFTEEN_MINUTES;
else if (lastUsedAgo < Constants.LAST_USAGE_THRESHOLD_RECENTLY_MS)
alarmInterval = AlarmManager.INTERVAL_HALF_DAY;
else
alarmInterval = AlarmManager.INTERVAL_DAY;
log.info("last used {} minutes ago, rescheduling blockchain sync in roughly {} minutes",
lastUsedAgo / DateUtils.MINUTE_IN_MILLIS, alarmInterval / DateUtils.MINUTE_IN_MILLIS);
final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
final PendingIntent alarmIntent = PendingIntent.getService(context, 0,
new Intent(context, BlockchainServiceImpl.class), 0);
alarmManager.cancel(alarmIntent);
// workaround for no inexact set() before KitKat
final long now = System.currentTimeMillis();
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, now + alarmInterval, AlarmManager.INTERVAL_DAY,
alarmIntent);
}
示例3: persistUpdateIntervalIndex
public static void persistUpdateIntervalIndex(int intervalIndex, Context context) {
long intervalValue;
switch(intervalIndex) {
case 0:
intervalValue = 0;
break;
case 1:
intervalValue = AlarmManager.INTERVAL_HOUR;
break;
case 2:
intervalValue = AlarmManager.INTERVAL_HALF_DAY;
break;
case 3:
intervalValue = AlarmManager.INTERVAL_DAY;
break;
default:
intervalValue = OTAListener.DEFAULT_INTERVAL_VALUE;
break;
}
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
sharedPreferences.edit().putLong(UPDATE_INTERVAL, intervalValue).apply();
if (intervalValue > 0) {
WakefulIntentService.cancelAlarms(context);
WakefulIntentService.scheduleAlarms(new OTAListener(), context, true);
OTAUtils.toast(R.string.autoupdate_enabled, context);
} else {
WakefulIntentService.cancelAlarms(context);
OTAUtils.toast(R.string.autoupdate_disabled, context);
}
}
示例4: getUpdateIntervalIndex
public static int getUpdateIntervalIndex(Context context) {
long value = getUpdateIntervalTime(context);
int index;
if (value == 0) {
index = 0;
} else if (value == AlarmManager.INTERVAL_HOUR) {
index = 1;
} else if (value == AlarmManager.INTERVAL_HALF_DAY) {
index = 2;
} else {
index = 3;
}
return index;
}