Java Code Examples for android.app.job.JobParameters#getExtras()
The following examples show how to use
android.app.job.JobParameters#getExtras() .
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: PlatformScheduler.java From MediaSDK with Apache License 2.0 | 6 votes |
@Override public boolean onStartJob(JobParameters params) { logd("PlatformSchedulerService started"); PersistableBundle extras = params.getExtras(); Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS)); if (requirements.checkRequirements(this)) { logd("Requirements are met"); String serviceAction = extras.getString(KEY_SERVICE_ACTION); String servicePackage = extras.getString(KEY_SERVICE_PACKAGE); Intent intent = new Intent(Assertions.checkNotNull(serviceAction)).setPackage(servicePackage); logd("Starting service action: " + serviceAction + " package: " + servicePackage); Util.startForegroundService(this, intent); } else { logd("Requirements are not met"); jobFinished(params, /* needsReschedule */ true); } return false; }
Example 2
Source File: PlatformScheduler.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public boolean onStartJob(JobParameters params) { logd("PlatformSchedulerService started"); PersistableBundle extras = params.getExtras(); Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS)); if (requirements.checkRequirements(this)) { logd("Requirements are met"); String serviceAction = extras.getString(KEY_SERVICE_ACTION); String servicePackage = extras.getString(KEY_SERVICE_PACKAGE); Intent intent = new Intent(serviceAction).setPackage(servicePackage); logd("Starting service action: " + serviceAction + " package: " + servicePackage); Util.startForegroundService(this, intent); } else { logd("Requirements are not met"); jobFinished(params, /* needsReschedule */ true); } return false; }
Example 3
Source File: PlatformScheduler.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public boolean onStartJob(JobParameters params) { logd("PlatformSchedulerService started"); PersistableBundle extras = params.getExtras(); Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS)); if (requirements.checkRequirements(this)) { logd("Requirements are met"); String serviceAction = extras.getString(KEY_SERVICE_ACTION); String servicePackage = extras.getString(KEY_SERVICE_PACKAGE); Intent intent = new Intent(serviceAction).setPackage(servicePackage); logd("Starting service action: " + serviceAction + " package: " + servicePackage); Util.startForegroundService(this, intent); } else { logd("Requirements are not met"); jobFinished(params, /* needsReschedule */ true); } return false; }
Example 4
Source File: AndroidJobScheduler.java From android_job_scheduler with Apache License 2.0 | 6 votes |
@Override public boolean onStartJob(JobParameters params) { PersistableBundle extras = params.getExtras(); Context context = getApplicationContext(); if (isApplicationRunning(context)) { if (callbackMethodChannel != null) { callbackMethodChannel.invokeMethod("firedWhileApplicationRunning", null); } } else { FlutterNativeView nativeView = new FlutterNativeView(context); if (AndroidJobScheduler.pluginRegistrantCallback != null) { AndroidJobScheduler.pluginRegistrantCallback.registerWith(nativeView.getPluginRegistry()); } nativeView.runFromBundle(FlutterMain.findAppBundlePath(context), null, extras.getString(B_KEY_DART_CB), true); } if (!extras.containsKey(B_KEY_SCHEDULE_ONCE)) { AndroidJobScheduler.scheduleEvery(getApplicationContext(), AndroidJobSchedulerUtils.persistableBundleToJobInfo(extras)); } jobFinished(params, false); return true; }
Example 5
Source File: FetchJobService.java From transistor-background-fetch with MIT License | 6 votes |
@Override public boolean onStartJob(final JobParameters params) { PersistableBundle extras = params.getExtras(); final String taskId = extras.getString(BackgroundFetchConfig.FIELD_TASK_ID); CompletionHandler completionHandler = new CompletionHandler() { @Override public void finish() { Log.d(BackgroundFetch.TAG, "- jobFinished"); jobFinished(params, false); } }; BGTask task = new BGTask(taskId, completionHandler, params.getJobId()); BackgroundFetch.getInstance(getApplicationContext()).onFetch(task); return true; }
Example 6
Source File: NotificationJobService.java From 365browser with Apache License 2.0 | 6 votes |
/** * Called when a Notification has been interacted with by the user. If we can verify that * the Intent has a notification Id, start Chrome (if needed) on the UI thread. * * We get a wakelock for our process for the duration of this method. * * @return True if there is more work to be done to handle the job, to signal we would like our * wakelock extended until we call {@link #jobFinished}. False if we have finished handling the * job. */ @Override public boolean onStartJob(final JobParameters params) { PersistableBundle extras = params.getExtras(); if (!extras.containsKey(NotificationConstants.EXTRA_NOTIFICATION_ID) || !extras.containsKey(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN) || !extras.containsKey(NotificationConstants.EXTRA_NOTIFICATION_INFO_TAG)) { return false; } Intent intent = new Intent(extras.getString(NotificationConstants.EXTRA_NOTIFICATION_ACTION)); intent.putExtras(new Bundle(extras)); ThreadUtils.assertOnUiThread(); NotificationService.dispatchIntentOnUIThread(this, intent); // TODO(crbug.com/685197): Return true here and call jobFinished to release the wake // lock only after the event has been completely handled by the service worker. return false; }
Example 7
Source File: PlatformScheduler.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public boolean onStartJob(JobParameters params) { logd("PlatformSchedulerService started"); PersistableBundle extras = params.getExtras(); Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS)); if (requirements.checkRequirements(this)) { logd("Requirements are met"); String serviceAction = extras.getString(KEY_SERVICE_ACTION); String servicePackage = extras.getString(KEY_SERVICE_PACKAGE); Intent intent = new Intent(Assertions.checkNotNull(serviceAction)).setPackage(servicePackage); logd("Starting service action: " + serviceAction + " package: " + servicePackage); Util.startForegroundService(this, intent); } else { logd("Requirements are not met"); jobFinished(params, /* needsReschedule */ true); } return false; }
Example 8
Source File: PlatformScheduler.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public boolean onStartJob(JobParameters params) { logd("PlatformSchedulerService started"); PersistableBundle extras = params.getExtras(); Requirements requirements = new Requirements(extras.getInt(KEY_REQUIREMENTS)); if (requirements.checkRequirements(this)) { logd("Requirements are met"); String serviceAction = extras.getString(KEY_SERVICE_ACTION); String servicePackage = extras.getString(KEY_SERVICE_PACKAGE); Intent intent = new Intent(Assertions.checkNotNull(serviceAction)).setPackage(servicePackage); logd("Starting service action: " + serviceAction + " package: " + servicePackage); Util.startForegroundService(this, intent); } else { logd("Requirements are not met"); jobFinished(params, /* needsReschedule */ true); } return false; }
Example 9
Source File: BackgroundTaskSchedulerJobService.java From 365browser with Apache License 2.0 | 5 votes |
/** * Retrieves the {@link TaskParameters} from the {@link JobParameters}, which are passed as * one of the keys. Only values valid for {@link android.os.BaseBundle} are supported, and other * values are stripped at the time when the task is scheduled. * * @param jobParameters the {@link JobParameters} to extract the {@link TaskParameters} from. * @return the {@link TaskParameters} for the current job. */ static TaskParameters getTaskParametersFromJobParameters(JobParameters jobParameters) { TaskParameters.Builder builder = TaskParameters.create(jobParameters.getJobId()); PersistableBundle jobExtras = jobParameters.getExtras(); PersistableBundle persistableTaskExtras = jobExtras.getPersistableBundle(BACKGROUND_TASK_EXTRAS_KEY); Bundle taskExtras = new Bundle(); taskExtras.putAll(persistableTaskExtras); builder.addExtras(taskExtras); return builder.build(); }
Example 10
Source File: BackgroundTaskSchedulerJobService.java From 365browser with Apache License 2.0 | 4 votes |
private static String getBackgroundTaskClassFromJobParameters(JobParameters jobParameters) { PersistableBundle extras = jobParameters.getExtras(); if (extras == null) return null; return extras.getString(BACKGROUND_TASK_CLASS_KEY); }