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


Java GcmNetworkManager.cancelTask方法代码示例

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


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

示例1: removeScheduledTasks

import com.google.android.gms.gcm.GcmNetworkManager; //导入方法依赖的package包/类
private static boolean removeScheduledTasks(GcmNetworkManager scheduler) {
    // Third-party code causes broadcast to touch disk. http://crbug.com/614679
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        scheduler.cancelTask(TASK_TAG, ChromeBackgroundService.class);
    } catch (IllegalArgumentException e) {
        // This occurs when BackgroundSyncLauncherService is not found in the application
        // manifest. This should not happen in code that reaches here, but has been seen in
        // the past. See https://crbug.com/548314
        // Disable GCM for the remainder of this session.
        setGCMEnabled(false);
        // Return false so that the failure will be logged.
        return false;
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
    return true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:BackgroundSyncLauncher.java

示例2: schedule

import com.google.android.gms.gcm.GcmNetworkManager; //导入方法依赖的package包/类
public void schedule(@NonNull GcmNetworkManager networkManager) throws IllegalStateException{
    if (tag == null) {
        throw new IllegalStateException("Tag cannot be null for WindowTask, it is used for rescheduling to the right time");
    }
    else if (windowHours == 0) {
        throw new IllegalStateException("Window hours not defined");
    }

    if (extras == null){
        extras = new Bundle();
    }
    extras.putBoolean(KEY_REQUIRES_CHARGING, requiresCharging);
    extras.putInt(KEY_REQUIRED_NETWORK, requiredNetworkState);
    extras.putInt(KEY_WINDOW_HOURS, windowHours);
    extras.putInt(KEY_START_MINUTE, startMinute);
    extras.putInt(KEY_START_HOUR, startHour);
    extras.putBoolean(KEY_PERSISTED, persisted);
    extras.putBoolean(KEY_UPDATE_CURRENT, updateCurrent);
    extras.putBoolean(KEY_STRICT, strict);

    networkManager.cancelTask(tag, service);
    PeriodicTask.Builder task = new PeriodicTask.Builder()
            .setService(service)
            .setPersisted(persisted)
            .setRequiresCharging(requiresCharging)
            .setRequiredNetwork(requiredNetworkState)
            .setTag(tag)
            .setUpdateCurrent(updateCurrent)
            .setExtras(extras)
            .setPeriod(getPeriod())
            .setFlex(windowHours * 60);
    networkManager.schedule(task.build());
}
 
开发者ID:raveeshbhalla,项目名称:WindowJobScheduler,代码行数:34,代码来源:WindowTask.java

示例3: cancel

import com.google.android.gms.gcm.GcmNetworkManager; //导入方法依赖的package包/类
@Override
public void cancel(Context context, int taskId) {
    ThreadUtils.assertOnUiThread();

    GcmNetworkManager gcmNetworkManager = getGcmNetworkManager(context);
    if (gcmNetworkManager == null) {
        Log.e(TAG, "GcmNetworkManager is not available.");
        return;
    }

    gcmNetworkManager.cancelTask(taskIdToTaskTag(taskId), BackgroundTaskGcmTaskService.class);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:13,代码来源:BackgroundTaskSchedulerGcmNetworkManager.java

示例4: unschedule

import com.google.android.gms.gcm.GcmNetworkManager; //导入方法依赖的package包/类
/**
 * Cancel any outstanding GCM Network Manager requests.
 */
public static void unschedule(Context context) {
    // Get the GCM Network Scheduler.
    GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(context);
    gcmNetworkManager.cancelTask(OfflinePageUtils.TASK_TAG, ChromeBackgroundService.class);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:9,代码来源:BackgroundScheduler.java

示例5: cancelTask

import com.google.android.gms.gcm.GcmNetworkManager; //导入方法依赖的package包/类
/**
 * Cancels a download resumption task if it is scheduled.
 */
public void cancelTask() {
    GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(mContext);
    gcmNetworkManager.cancelTask(TASK_TAG, ChromeBackgroundService.class);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:DownloadResumptionScheduler.java

示例6: onClick

import com.google.android.gms.gcm.GcmNetworkManager; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    GcmNetworkManager gcmNM = GcmNetworkManager.getInstance(AccountSettingsActivity.this);
    Log.i(TAG, "Cancelling Periodic BackupTask");
    gcmNM.cancelTask(TASK_PERIODIC_BACKUP, MyBackupService.class);
}
 
开发者ID:PacktPublishing,项目名称:Asynchronous-Android-Programming,代码行数:7,代码来源:AccountSettingsActivity.java

示例7: cancel

import com.google.android.gms.gcm.GcmNetworkManager; //导入方法依赖的package包/类
@Override
public void cancel() {
    GcmNetworkManager gcmNetworkManager = getGcmNetworkManager();
    if (gcmNetworkManager == null) return;
    gcmNetworkManager.cancelTask(OfflinePageUtils.TASK_TAG, ChromeBackgroundService.class);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:7,代码来源:BackgroundGcmScheduler.java


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