Java Code Examples for android.app.job.JobInfo#getId()
The following examples show how to use
android.app.job.JobInfo#getId() .
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: VJobSchedulerService.java From container with GNU General Public License v3.0 | 6 votes |
@Override public int schedule(JobInfo job) throws RemoteException { int vuid = VBinder.getCallingUid(); int id = job.getId(); ComponentName service = job.getService(); JobId jobId = new JobId(vuid, service.getPackageName(), id); JobConfig config = mJobStore.get(jobId); if (config == null) { config = new JobConfig(mGlobalJobId++, service.getClassName(), job.getExtras()); mJobStore.put(jobId, config); } else { config.serviceName = service.getClassName(); config.extras = job.getExtras(); } saveJobs(); mirror.android.app.job.JobInfo.jobId.set(job, config.virtualJobId); mirror.android.app.job.JobInfo.service.set(job, mJobProxyComponent); return mScheduler.schedule(job); }
Example 2
Source File: SyncManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private boolean isJobIdInUseLockedH(int jobId, List<JobInfo> pendingJobs) { for (JobInfo job: pendingJobs) { if (job.getId() == jobId) { return true; } } for (ActiveSyncContext asc: mActiveSyncContexts) { if (asc.mSyncOperation.jobId == jobId) { return true; } } return false; }
Example 3
Source File: JobInfoScheduler.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
private boolean isJobServiceOn(JobScheduler scheduler, int jobId, int attemptNumber) { for (JobInfo jobInfo : scheduler.getAllPendingJobs()) { int existingAttemptNumber = jobInfo.getExtras().getInt(ATTEMPT_NUMBER); if (jobInfo.getId() == jobId) { return existingAttemptNumber >= attemptNumber; } } return false; }
Example 4
Source File: MainActivity.java From your-local-weather with GNU General Public License v3.0 | 5 votes |
private void startAlarms() { appendLog(this, TAG, "scheduleStart at boot, SDK=", Build.VERSION.SDK_INT); if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M) { JobScheduler jobScheduler = getSystemService(JobScheduler.class); boolean scheduled = false; for (JobInfo jobInfo: jobScheduler.getAllPendingJobs()) { if (jobInfo.getId() > 0) { appendLog(this, TAG, "scheduleStart does not start - it's scheduled already"); scheduled = true; break; } } if (!scheduled) { appendLog(this, TAG, "scheduleStart at MainActivity"); AppPreference.setLastSensorServicesCheckTimeInMs(this, 0); jobScheduler.cancelAll(); ComponentName serviceComponent = new ComponentName(this, StartAutoLocationJob.class); JobInfo.Builder builder = new JobInfo.Builder(StartAutoLocationJob.JOB_ID, serviceComponent); builder.setMinimumLatency(1 * 1000); // wait at least builder.setOverrideDeadline(3 * 1000); // maximum delay jobScheduler.schedule(builder.build()); } } else { Intent intentToStartUpdate = new Intent("org.thosp.yourlocalweather.action.START_ALARM_SERVICE"); intentToStartUpdate.setPackage("org.thosp.yourlocalweather"); startService(intentToStartUpdate); } }
Example 5
Source File: NetworkLocationProvider.java From your-local-weather with GNU General Public License v3.0 | 5 votes |
private void sendUpdateToLocationBackends() { appendLog(getBaseContext(), TAG, "update():nextScanningAllowedFrom:", nextScanningAllowedFrom); if(nextScanningAllowedFrom == null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { scanning = wifiManager.startScan(); } else { scanning = true; } if (scanning) { nextScanningAllowedFrom = Calendar.getInstance(); nextScanningAllowedFrom.add(Calendar.MINUTE, 15); } } if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M) { ComponentName serviceComponent = new ComponentName(this, NetworkLocationCellsOnlyJob.class); JobInfo.Builder builder = new JobInfo.Builder(NetworkLocationCellsOnlyJob.JOB_ID, serviceComponent); builder.setMinimumLatency(8000); // wait at least builder.setOverrideDeadline(10000); // maximum delay JobInfo jobInfo = builder.build(); jobId= jobInfo.getId(); JobScheduler jobScheduler = getSystemService(JobScheduler.class); jobScheduler.schedule(jobInfo); } else { intentToCancel = getIntentToGetCellsOnly(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { alarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 8000, intentToCancel); } else { alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 8000, intentToCancel); } } appendLog(getBaseContext(), TAG, "update():cells only task scheduled"); }
Example 6
Source File: AppUtils.java From ClassSchedule with Apache License 2.0 | 5 votes |
private static boolean isJobPollServiceOn(Context context) { JobScheduler scheduler = (JobScheduler) context .getSystemService(Context.JOB_SCHEDULER_SERVICE); for (JobInfo jobInfo : scheduler.getAllPendingJobs()) { if (jobInfo.getId() == UPDATE_WIDGET_JOB_ID) { return true; } } return false; }
Example 7
Source File: NotificationsJobService.java From intra42 with Apache License 2.0 | 5 votes |
public static void schedule(Context context) { JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); if (jobScheduler == null) return; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (jobScheduler.getPendingJob(JOB_ID) != null) return; } else { List<JobInfo> allPendingJobs = jobScheduler.getAllPendingJobs(); if (!allPendingJobs.isEmpty()) { for (JobInfo j : allPendingJobs) { if (j.getId() == JOB_ID) return; } } } SharedPreferences settings = AppSettings.getSharedPreferences(context); int notificationsFrequency = AppSettings.Notifications.getNotificationsFrequency(settings); ComponentName component = new ComponentName(context, NotificationsJobService.class); JobInfo.Builder builder = new JobInfo.Builder(JOB_ID, component) .setPeriodic(60000 * notificationsFrequency); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_NOT_ROAMING); else builder.setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY); jobScheduler.schedule(builder.build()); }
Example 8
Source File: ServiceScheduler.java From android-sdk with Apache License 2.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private static boolean isScheduled(Context context, Integer jobId) { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE); for (JobInfo jobInfo : jobScheduler.getAllPendingJobs()) { // we only don't allow rescheduling of periodic jobs. jobs for individual // intents such as events are allowed and can end up queued in the job service queue. if (jobInfo.getId() == jobId && jobInfo.isPeriodic()) { return true; } } } return false; }
Example 9
Source File: JobProxy21.java From android-job with Apache License 2.0 | 5 votes |
@SuppressWarnings("SimplifiableIfStatement") protected boolean isJobInfoScheduled(@Nullable JobInfo info, @NonNull JobRequest request) { boolean correctInfo = info != null && info.getId() == request.getJobId(); if (!correctInfo) { return false; } return !request.isTransient() || TransientBundleCompat.isScheduled(mContext, request.getJobId()); }
Example 10
Source File: JobProxy26.java From android-job with Apache License 2.0 | 4 votes |
@Override protected boolean isJobInfoScheduled(@Nullable JobInfo info, @NonNull JobRequest request) { return info != null && info.getId() == request.getJobId(); }