本文整理匯總了Java中android.app.AlarmManager.INTERVAL_FIFTEEN_MINUTES屬性的典型用法代碼示例。如果您正苦於以下問題:Java AlarmManager.INTERVAL_FIFTEEN_MINUTES屬性的具體用法?Java AlarmManager.INTERVAL_FIFTEEN_MINUTES怎麽用?Java AlarmManager.INTERVAL_FIFTEEN_MINUTES使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.app.AlarmManager
的用法示例。
在下文中一共展示了AlarmManager.INTERVAL_FIFTEEN_MINUTES屬性的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: noAlarm
private boolean noAlarm() {
long lastAlarm = PreferencesUtils.getPreferences(this)
.getLong(BreventReceiver.ALARM_TIME, 0);
if (lastAlarm > 0) {
final long maxAlarmTime = 0x2 * AlarmManager.INTERVAL_FIFTEEN_MINUTES;
if (SystemClock.elapsedRealtime() - lastAlarm > maxAlarmTime) {
return true;
}
}
return false;
}
示例3: parseInterval
/**
* Parse repeat interval.
*/
private void parseInterval() {
String every = options.optString("every").toLowerCase();
if (every.isEmpty()) {
interval = 0;
} else
if (every.equals("second")) {
interval = 1000;
} else
if (every.equals("minute")) {
interval = AlarmManager.INTERVAL_FIFTEEN_MINUTES / 15;
} else
if (every.equals("hour")) {
interval = AlarmManager.INTERVAL_HOUR;
} else
if (every.equals("day")) {
interval = AlarmManager.INTERVAL_DAY;
} else
if (every.equals("week")) {
interval = AlarmManager.INTERVAL_DAY * 7;
} else
if (every.equals("month")) {
interval = AlarmManager.INTERVAL_DAY * 31;
} else
if (every.equals("quarter")) {
interval = AlarmManager.INTERVAL_HOUR * 2190;
} else
if (every.equals("year")) {
interval = AlarmManager.INTERVAL_DAY * 365;
} else {
try {
interval = Integer.parseInt(every) * 60000;
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例4: 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);
}