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


Java Task.NETWORK_STATE_UNMETERED属性代码示例

本文整理汇总了Java中com.google.android.gms.gcm.Task.NETWORK_STATE_UNMETERED属性的典型用法代码示例。如果您正苦于以下问题:Java Task.NETWORK_STATE_UNMETERED属性的具体用法?Java Task.NETWORK_STATE_UNMETERED怎么用?Java Task.NETWORK_STATE_UNMETERED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.android.gms.gcm.Task的用法示例。


在下文中一共展示了Task.NETWORK_STATE_UNMETERED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: schedule

/**
 * Schedules a future task to start download resumption.
 * @param allowMeteredConnection Whether download resumption can start if connection is metered.
 */
public void schedule(boolean allowMeteredConnection) {
    GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(mContext);
    int networkType = allowMeteredConnection
            ? Task.NETWORK_STATE_CONNECTED : Task.NETWORK_STATE_UNMETERED;
    OneoffTask task = new OneoffTask.Builder()
            .setService(ChromeBackgroundService.class)
            .setExecutionWindow(0, ONE_DAY_IN_SECONDS)
            .setTag(TASK_TAG)
            .setUpdateCurrent(true)
            .setRequiredNetwork(networkType)
            .setRequiresCharging(false)
            .build();
    try {
        gcmNetworkManager.schedule(task);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "unable to schedule resumption task.", e);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:DownloadResumptionScheduler.java

示例2: schedule

/**
 * Schedules a future task to start download resumption.
 * @param allowMeteredConnection Whether download resumption can start if connection is metered.
 */
public void schedule(boolean allowMeteredConnection) {
    GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(mContext);
    int networkType = allowMeteredConnection
            ? Task.NETWORK_STATE_CONNECTED : Task.NETWORK_STATE_UNMETERED;
    OneoffTask task = new OneoffTask.Builder()
                              .setService(ChromeBackgroundService.class)
                              .setExecutionWindow(0, ONE_DAY_IN_SECONDS)
                              .setTag(TASK_TAG)
                              .setUpdateCurrent(true)
                              .setRequiredNetwork(networkType)
                              .setRequiresCharging(false)
                              .build();
    try {
        gcmNetworkManager.schedule(task);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "unable to schedule resumption task.", e);
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:22,代码来源:DownloadResumptionScheduler.java

示例3: convertNetworkType

protected int convertNetworkType(@NonNull JobRequest.NetworkType networkType) {
    switch (networkType) {
        case ANY:
            return Task.NETWORK_STATE_ANY;
        case CONNECTED:
            return Task.NETWORK_STATE_CONNECTED;
        case UNMETERED:
            return Task.NETWORK_STATE_UNMETERED;
        case NOT_ROAMING:
            return Task.NETWORK_STATE_UNMETERED; // use as fallback, NOT_ROAMING not supported
        default:
            throw new IllegalStateException("not implemented");
    }
}
 
开发者ID:evernote,项目名称:android-job,代码行数:14,代码来源:JobProxyGcm.java


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