当前位置: 首页>>代码示例>>Java>>正文


Java AlarmManager.INTERVAL_FIFTEEN_MINUTES属性代码示例

本文整理汇总了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;
    }
}
 
开发者ID:hichemcesar24,项目名称:Weather-Android,代码行数:19,代码来源:AlarmReceiver.java

示例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;
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:11,代码来源:BreventActivity.java

示例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();
        }
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:40,代码来源:Options.java

示例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);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:27,代码来源:WalletApplication.java


注:本文中的android.app.AlarmManager.INTERVAL_FIFTEEN_MINUTES属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。