當前位置: 首頁>>代碼示例>>Java>>正文


Java AlarmManager.INTERVAL_HALF_DAY屬性代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:hichemcesar24,項目名稱:Weather-Android,代碼行數:19,代碼來源:AlarmReceiver.java

示例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);
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:27,代碼來源:WalletApplication.java

示例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);
    }
}
 
開發者ID:DroidThug,項目名稱:VulcanOTA,代碼行數:31,代碼來源:AppConfig.java

示例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;
}
 
開發者ID:DroidThug,項目名稱:VulcanOTA,代碼行數:14,代碼來源:AppConfig.java


注:本文中的android.app.AlarmManager.INTERVAL_HALF_DAY屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。