Search in sources :

Example 1 with JobManager

use of com.evernote.android.job.JobManager in project android by nextcloud.

the class ContactsPreferenceActivity method cancelContactBackupJobForAccount.

public static void cancelContactBackupJobForAccount(Context context, Account account) {
    Log_OC.d(TAG, "disabling contacts backup job for account: " + account.name);
    JobManager jobManager = JobManager.create(context);
    Set<JobRequest> jobs = jobManager.getAllJobRequestsForTag(ContactsBackupJob.TAG);
    for (JobRequest jobRequest : jobs) {
        PersistableBundleCompat extras = jobRequest.getExtras();
        if (extras.getString(ContactsBackupJob.ACCOUNT, "").equalsIgnoreCase(account.name)) {
            jobManager.cancel(jobRequest.getJobId());
        }
    }
}
Also used : JobRequest(com.evernote.android.job.JobRequest) PersistableBundleCompat(com.evernote.android.job.util.support.PersistableBundleCompat) JobManager(com.evernote.android.job.JobManager)

Example 2 with JobManager

use of com.evernote.android.job.JobManager in project PhoneProfilesPlus by henrichg.

the class GeofenceScannerJob method _cancelJob.

private static void _cancelJob() /*final Context context*/
{
    try {
        JobManager jobManager = JobManager.instance();
        jobManager.cancelAllForTag(JOB_TAG_START);
        jobManager.cancelAllForTag(JOB_TAG);
    } catch (Exception ignored) {
    }
}
Also used : JobManager(com.evernote.android.job.JobManager)

Example 3 with JobManager

use of com.evernote.android.job.JobManager in project PhoneProfilesPlus by henrichg.

the class WifiScanJob method _cancelJob.

private static void _cancelJob(final Context context) {
    WifiScanJob.setScanRequest(context, false);
    WifiScanJob.setWaitForResults(context, false);
    WifiScanJob.setWifiEnabledForScan(context, false);
    WifiBluetoothScanner.setForceOneWifiScan(context, WifiBluetoothScanner.FORCE_ONE_SCAN_DISABLED);
    try {
        JobManager jobManager = JobManager.instance();
        jobManager.cancelAllForTag(JOB_TAG_SHORT);
        jobManager.cancelAllForTag(JOB_TAG);
    } catch (Exception ignored) {
    }
}
Also used : JobManager(com.evernote.android.job.JobManager)

Example 4 with JobManager

use of com.evernote.android.job.JobManager in project PhoneProfilesPlus by henrichg.

the class BluetoothScanJob method _cancelJob.

private static void _cancelJob(final Context context) {
    BluetoothScanJob.setScanRequest(context, false);
    BluetoothScanJob.setWaitForResults(context, false);
    BluetoothScanJob.setLEScanRequest(context, false);
    BluetoothScanJob.setWaitForLEResults(context, false);
    BluetoothScanJob.setBluetoothEnabledForScan(context, false);
    WifiBluetoothScanner.setForceOneBluetoothScan(context, WifiBluetoothScanner.FORCE_ONE_SCAN_DISABLED);
    WifiBluetoothScanner.setForceOneLEBluetoothScan(context, WifiBluetoothScanner.FORCE_ONE_SCAN_DISABLED);
    try {
        JobManager jobManager = JobManager.instance();
        jobManager.cancelAllForTag(JOB_TAG_SHORT);
        jobManager.cancelAllForTag(JOB_TAG);
    } catch (Exception ignored) {
    }
}
Also used : JobManager(com.evernote.android.job.JobManager)

Example 5 with JobManager

use of com.evernote.android.job.JobManager in project android by nextcloud.

the class ContactsPreferenceActivity method cancelPreviousContactBackupJobForAccount.

public static void cancelPreviousContactBackupJobForAccount(Context context, Account account) {
    Log_OC.d(TAG, "disabling existing contacts backup job for account: " + account.name);
    JobManager jobManager = JobManager.create(context);
    Set<JobRequest> jobs = jobManager.getAllJobRequestsForTag(ContactsBackupJob.TAG);
    for (JobRequest jobRequest : jobs) {
        PersistableBundleCompat extras = jobRequest.getExtras();
        if (extras.getString(ContactsBackupJob.ACCOUNT, "").equalsIgnoreCase(account.name) && jobRequest.isPeriodic()) {
            jobManager.cancel(jobRequest.getJobId());
        }
    }
}
Also used : JobRequest(com.evernote.android.job.JobRequest) PersistableBundleCompat(com.evernote.android.job.util.support.PersistableBundleCompat) JobManager(com.evernote.android.job.JobManager)

Aggregations

JobManager (com.evernote.android.job.JobManager)12 JobRequest (com.evernote.android.job.JobRequest)8 PersistableBundleCompat (com.evernote.android.job.util.support.PersistableBundleCompat)2 SuppressLint (android.annotation.SuppressLint)1