Java Code Examples for com.google.android.gms.gcm.GcmNetworkManager#cancelTask()

The following examples show how to use com.google.android.gms.gcm.GcmNetworkManager#cancelTask() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackgroundSyncLauncher.java    From delion with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: BackgroundSyncLauncher.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: BackgroundSyncLauncher.java    From 365browser with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: BackgroundTaskSchedulerGcmNetworkManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: BackgroundScheduler.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 6
Source File: DownloadResumptionScheduler.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Cancels a download resumption task if it is scheduled.
 */
public void cancelTask() {
    GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(mContext);
    gcmNetworkManager.cancelTask(TASK_TAG, ChromeBackgroundService.class);
}
 
Example 7
Source File: BackgroundScheduler.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 8
Source File: DownloadResumptionScheduler.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Cancels a download resumption task if it is scheduled.
 */
public void cancelTask() {
    GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(mContext);
    gcmNetworkManager.cancelTask(TASK_TAG, ChromeBackgroundService.class);
}
 
Example 9
Source File: BackgroundGcmScheduler.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void cancel() {
    GcmNetworkManager gcmNetworkManager = getGcmNetworkManager();
    if (gcmNetworkManager == null) return;
    gcmNetworkManager.cancelTask(OfflinePageUtils.TASK_TAG, ChromeBackgroundService.class);
}
 
Example 10
Source File: DownloadResumptionScheduler.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Cancels a download resumption task if it is scheduled.
 */
public void cancelTask() {
    GcmNetworkManager gcmNetworkManager = GcmNetworkManager.getInstance(mContext);
    gcmNetworkManager.cancelTask(TASK_TAG, ChromeBackgroundService.class);
}