List of usage examples for android.app.job JobParameters getExtras
public @NonNull PersistableBundle getExtras()
From source file:com.owncloud.android.files.services.RetryDownloadJobService.java
@Override public boolean onStartJob(JobParameters jobParameters) { String accountName = jobParameters.getExtras().getString(Extras.EXTRA_ACCOUNT_NAME); Account account = AccountUtils.getOwnCloudAccountByName(this, accountName); // Check if the account has been deleted after downloading the file and before // retrying the download if (account != null) { FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(this, account, getContentResolver());//from ww w .ja v a 2 s.c o m String fileRemotePath = jobParameters.getExtras().getString(Extras.EXTRA_REMOTE_PATH); Log_OC.d(TAG, String.format("Retrying download of %1s in %2s", fileRemotePath, accountName)); // Get download file from database OCFile ocFile = fileDataStorageManager.getFileByPath(fileRemotePath); if (ocFile != null) { // Retry download Intent intent = new Intent(this, FileDownloader.class); intent.putExtra(FileDownloader.KEY_ACCOUNT, account); intent.putExtra(FileDownloader.KEY_FILE, ocFile); intent.putExtra(FileDownloader.KEY_RETRY_DOWNLOAD, true); ContextCompat.startForegroundService(this, intent); } else { Log_OC.w(TAG, String.format("File %1s in %2s not found in database", fileRemotePath, accountName)); } } else { Log_OC.w(TAG, String.format("Account %1s was deleted, no retry will be done", accountName)); } jobFinished(jobParameters, false); // done here, real job was delegated to another castle return true; // TODO or false? what is the real effect, Google!?!?!?!? }
From source file:nuclei.task.TaskJobService.java
@Override @SuppressWarnings("unchecked") public boolean onStartJob(JobParameters params) { try {/*from w w w .j ava 2 s. c o m*/ if (sTaskPool == null) throw new NullPointerException("TaskJobService TaskPool not set!"); BaseBundle bundle = params.getExtras(); String taskName = bundle.getString(TaskScheduler.TASK_NAME); Task task = (Task) Class.forName(taskName).newInstance(); ArrayMap<String, Object> map = new ArrayMap<>(bundle.size()); for (String key : bundle.keySet()) { map.put(key, bundle.get(key)); } task.deserialize(map); if (task instanceof HttpTask) Http.execute((HttpTask) task).addCallback(new JobCallback(params)); else sTaskPool.execute(task).addCallback(new JobCallback(params)); return true; } catch (Exception err) { LOG.e("Error running task", err); jobFinished(params, true); return false; } }
From source file:com.google.android.media.tv.companionlibrary.EpgSyncJobService.java
@Override public boolean onStartJob(JobParameters params) { if (DEBUG) {//from ww w.j a v a 2 s. c o m Log.d(TAG, "onStartJob(" + params.getJobId() + ")"); } // Broadcast status Intent intent = new Intent(ACTION_SYNC_STATUS_CHANGED); intent.putExtra(BUNDLE_KEY_INPUT_ID, params.getExtras().getString(BUNDLE_KEY_INPUT_ID)); intent.putExtra(SYNC_STATUS, SYNC_STARTED); LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent); EpgSyncTask epgSyncTask = new EpgSyncTask(params); synchronized (mTaskArray) { mTaskArray.put(params.getJobId(), epgSyncTask); } epgSyncTask.execute(); return true; }