本文整理汇总了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);
}
}
示例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");
}
}