Java 类android.app.job.JobParameters 实例源码

项目:AppLock    文件:AppsService.java   
@Override
public boolean onStartJob(JobParameters params){
    DataBase data=DataBase.getInstance(getApplicationContext());
    ActivityManager activityManager=(ActivityManager) getApplicationContext().getSystemService(getApplicationContext().ACTIVITY_SERVICE);
    final List<ActivityManager.RunningAppProcessInfo> info=activityManager.getRunningAppProcesses();
    if(info != null){
        for(final ActivityManager.RunningAppProcessInfo process : info){
            if(data.findInfo(process.processName)==1){
                Intent service=new Intent(getApplicationContext(),UnlockActivity.class);
                getApplicationContext().startService(service);
            }
        }
    }
    Util.Job(getApplicationContext());
    return true;
}
项目:AutoMusicTagFixer    文件:ScheduleJobService.java   
/**
 * Callback when service start, here is when we execute our
 * task in background, so an intensive task
 * needs to run in another thread because
 * this callback it executes on UI Thread
 * @param params Are the parameters with was built
 *                   the job
 * @return true for execute the code
 */

@Override
public boolean onStartJob(final JobParameters params) {
    Log.d("ONSTART","onstart");

    //We set context and initialize the GNSDK API if it was not before.
    if(ConnectivityDetector.sIsConnected) {
        //GnService.API_INITIALIZED_AFTER_CONNECTED flag indicates
        //that service was not initialized from Splash.
        //is useful to inform to user in MainActivity
        //that API of GNSDK has been initialized
        GnService.withContext(getApplicationContext()).initializeAPI(GnService.API_INITIALIZED_AFTER_CONNECTED);
    }

    //if is connected, we finalize this job
    jobFinished(params, !ConnectivityDetector.sIsConnected);
    return true;
}
项目:intra42    文件:NotificationsJobService.java   
@Override
public boolean onStartJob(final JobParameters params) {
    // I am on the main thread, so if you need to do background work,
    // be sure to start up an AsyncTask, Thread, or IntentService!

    final AppClass app = (AppClass) getApplication();

    if (app.userIsLogged(false))

        new Thread(new Runnable() {
            @Override
            public void run() {
                NotificationsUtils.run(getBaseContext(), app);
                jobFinished(params, true);
            }
        }).start();
    else
        jobFinished(params, false);
    return true;
}
项目:QuoteLock    文件:QuoteDownloaderService.java   
@Override
public boolean onStartJob(JobParameters params) {
    Xlog.d(TAG, "Quote downloader job started");

    if (params.getJobId() != JobUtils.JOB_ID) {
        Xlog.e(TAG, "Job ID mismatch, ignoring");
        return false;
    }

    if (!JobUtils.shouldRefreshQuote(this)) {
        Xlog.d(TAG, "Should not refresh quote now, ignoring");
        return false;
    }

    mUpdaterTask = new ServiceQuoteDownloaderTask(params);
    mUpdaterTask.execute();
    return true;
}
项目:LatestDiscounts    文件:PollJobService.java   
@Override
protected List<DiscountItem> doInBackground(JobParameters... params) {
    JobParameters jobParams = params[0];

    Log.i(TAG, "Poll Smzdm for new product");

    List<DiscountItem> items;

    if (mQuery == null) {
        items = new SmzdmFetchr().fetchHomeDiscounts(1, "");
    } else {
        items = new SmzdmFetchr().searchDiscounts(0, mQuery);
    }

    jobFinished(jobParams, false);
    return items;
}
项目:nuclei-android    文件:TaskJobService.java   
@Override
@SuppressWarnings("unchecked")
public boolean onStartJob(JobParameters params) {
    try {
        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;
    }
}
项目:Asynchronous-Android-Programming    文件:SyncTask.java   
@Override
protected void onPostExecute(Result<JobParameters> result) {

    NotificationCompat.Builder builder =
            new NotificationCompat.Builder(jobService);
    NotificationManager nm = (NotificationManager) jobService.
            getSystemService(jobService.NOTIFICATION_SERVICE);
    builder.setSmallIcon( android.R.drawable.sym_def_app_icon);
    if ( result.exc!=null ) {
        jobService.jobFinished(result.result, true);
        builder.setContentTitle("Failed to sync account")
                .setContentText("Failed to sync account " + result.exc);
    } else{
        builder.setContentTitle("Account Updated")
                .setContentText("Updated Account Sucessfully at " + new Date().toString());
        jobService.jobFinished(result.result, false);
    }
    nm.notify(NOTIFICACTION_ID, builder.build());

}
项目:dns66    文件:RuleDatabaseUpdateJobService.java   
@Override
public boolean onStartJob(final JobParameters params) {
    Log.d(TAG, "onStartJob: Start job");
    task = new RuleDatabaseUpdateTask(this, FileHelper.loadCurrentSettings(this), true) {
        @Override
        protected void onPostExecute(Void aVoid) {
            super.onPostExecute(aVoid);
            jobFinished(params, task.pendingCount() > 0);
        }

        @Override
        protected void onCancelled(Void aVoid) {
            super.onCancelled(aVoid);
            jobFinished(params, task.pendingCount() > 0);
        }
    };
    task.execute();
    return false;
}
项目:MarketBot    文件:BotJobService.java   
@Override
        protected JobParameters[] doInBackground(JobParameters... params) {

            this.params = params[0];


//            mCurrentCharacter = new Character();
//            PersistableBundle bundle = mParams.getExtras();
//
//            mCurrentCharacter.setCharacterId(bundle.getLong(Constants.CHARACTER_ID));
//            mCurrentCharacter.setCharacterName(bundle.getString(Constants.CHARACTER_NAME));
//            mCurrentCharacter.setKeyId(bundle.getString(Constants.KEYID));
//            mCurrentCharacter.setvCode(bundle.getString(Constants.VCODE));
//
//            mApiService = new Api.Builder()
//                    .setTranquilityEndpoint()
//                    .build();
//
//            mApiService.getMailHeaders(mCurrentCharacter, this);

            // Do updating and stopping logical here.
            return params;
        }
项目:authentication    文件:ContentSynchronizationJobService.java   
@Override
    public boolean onStartJob(JobParameters params) {
        Log.i(getClass().getName(), "onStartJob");

        // Start processing work
        boolean isWifiEnabled = ConnectivityHelper.isWifiEnabled(getApplicationContext());
        Log.i(getClass().getName(), "isWifiEnabled: " + isWifiEnabled);
        boolean isWifiConnected = ConnectivityHelper.isWifiConnected(getApplicationContext());
        Log.i(getClass().getName(), "isWifiConnected: " + isWifiConnected);
        if (!isWifiEnabled) {
//            Toast.makeText(getApplicationContext(), getString(R.string.wifi_needs_to_be_enabled), Toast.LENGTH_SHORT).show();
            Log.i(getClass().getName(), getString(R.string.wifi_needs_to_be_enabled));
        } else if (!isWifiConnected) {
//            Toast.makeText(getApplicationContext(), getString(R.string.wifi_needs_to_be_connected), Toast.LENGTH_SHORT).show();
            Log.i(getClass().getName(), getString(R.string.wifi_needs_to_be_connected));
        } else {
            new ReadDeviceAsyncTask(getApplicationContext()).execute();
        }

        boolean isWorkProcessingPending = false;
        return isWorkProcessingPending;
    }
项目:lecture_examples    文件:MyJobService.java   
@Override
protected JobParameters doInBackground(JobParameters... jobParameterses) {

    Log.d(TAG, "We are running in MyTask in Job with ID: " + jobParameterses[0].getJobId());

    int retry = 0;

    while (!isCancelled() && retry < 10) {
        try {
            retry++;
            Log.d(TAG, "Sleeping " + retry + "/10");
            Thread.sleep(2 * 1000);
        } catch (Exception e) {
            Log.d(TAG, "Sleep has been interrupted");
        }
    }

    Log.d(TAG, "We are " + (isCancelled()?"not ":"") + "done with Job");
    if (isCancelled()) jobFinished(jobParameterses[0], true);

    return jobParameterses[0];
}
项目:BackPackTrackII    文件:JobExecutionService.java   
@Override
public boolean onStartJob(JobParameters jobParameters) {
    Log.i(TAG, "Start params=" + jobParameters);

    Intent intent = new Intent(this, BackgroundService.class);
    int id = jobParameters.getJobId();
    if (id == JOB_UPLOAD_GPX) {
        intent.setAction(BackgroundService.ACTION_UPLOAD_GPX);
        intent.putExtras(Util.getBundle(jobParameters.getExtras()));
    } else if (id == JOB_CONNECTIVITY)
        intent.setAction(BackgroundService.ACTION_CONNECTIVITY);
    else
        Log.w(TAG, "Unknown job id=" + id);

    Log.i(TAG, "Starting intent=" + intent);
    startService(intent);

    return false;
}
项目:365browser    文件:NotificationJobService.java   
/**
 * 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;
}
项目:365browser    文件:BackgroundTaskJobService.java   
@Override
public boolean onStartJob(JobParameters params) {
    ThreadUtils.assertOnUiThread();
    BackgroundTask backgroundTask =
            BackgroundTaskSchedulerJobService.getBackgroundTaskFromJobParameters(params);
    if (backgroundTask == null) {
        Log.w(TAG, "Failed to start task. Could not instantiate class.");
        return false;
    }

    mCurrentTasks.put(params.getJobId(), backgroundTask);

    TaskParameters taskParams =
            BackgroundTaskSchedulerJobService.getTaskParametersFromJobParameters(params);
    boolean taskNeedsBackgroundProcessing = backgroundTask.onStartTask(getApplicationContext(),
            taskParams, new TaskFinishedCallbackJobService(this, backgroundTask, params));

    if (!taskNeedsBackgroundProcessing) mCurrentTasks.remove(params.getJobId());
    return taskNeedsBackgroundProcessing;
}
项目:365browser    文件:BackgroundTaskJobService.java   
@Override
public boolean onStopJob(JobParameters params) {
    ThreadUtils.assertOnUiThread();
    if (!mCurrentTasks.containsKey(params.getJobId())) {
        Log.w(TAG, "Failed to stop job, because job with job id " + params.getJobId()
                        + " does not exist.");
        return false;
    }

    BackgroundTask backgroundTask = mCurrentTasks.get(params.getJobId());

    TaskParameters taskParams =
            BackgroundTaskSchedulerJobService.getTaskParametersFromJobParameters(params);
    boolean taskNeedsReschedule =
            backgroundTask.onStopTask(getApplicationContext(), taskParams);
    mCurrentTasks.remove(params.getJobId());
    return taskNeedsReschedule;
}
项目:dscautorename    文件:MediaContentJobService.java   
@Override
public boolean onStartJob(JobParameters params) {
    Context appCtx = getApplicationContext();
    if (appCtx instanceof DSCApplication) {
        DSCApplication application = (DSCApplication) appCtx;
        MediaContentJobService.log(appCtx, Log.DEBUG, TAG, "onStartJob()");
        Uri[] uris = params.getTriggeredContentUris();
        if (Utilities.isEmpty(uris)) {
            application.rescheduleMediaContentJobService();
        } else {
            if (!application.isRenameFileTaskRunning()) {
                application.launchAutoRenameTask(null, false, null, true);
            }
        }
    }
    return true;
}
项目:share-to-delete    文件:AutoCleanService.java   
@Override
public boolean onStartJob(JobParameters params) {
    context = this;
    notificationManagerCompat = NotificationManagerCompat.from(context);
    preferences = PreferenceManager.getDefaultSharedPreferences(context);
    if (!preferences.getBoolean(AutoCleanSettingsActivity.PREF_AUTO_CLEAN, false)) return false;
    sendNotification();
    cleanUp();
    sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            Log.v(MyUtil.PACKAGE_NAME, getString(R.string.toast_auto_clean, deletedFileCount));
            Toast.makeText(
                    context,
                    getString(R.string.toast_auto_clean, deletedFileCount),
                    Toast.LENGTH_SHORT
            ).show();
            notificationManagerCompat.cancel(NOTIFICATION_JOB_ID);
        }
    }, 3000);
    return true;
}
项目:androidtv-sample-inputs    文件:EpgSyncJobService.java   
@Override
public boolean onStartJob(JobParameters params) {
    if (DEBUG) {
        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;
}
项目:muzei    文件:ArtworkComplicationJobService.java   
@Override
public boolean onStartJob(JobParameters params) {
    ProviderUpdateRequester providerUpdateRequester = new ProviderUpdateRequester(this,
            new ComponentName(this, ArtworkComplicationProviderService.class));
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    Set<String> complicationSet = preferences.getStringSet(
            ArtworkComplicationProviderService.KEY_COMPLICATION_IDS, new TreeSet<>());
    if (!complicationSet.isEmpty()) {
        int[] complicationIds = new int[complicationSet.size()];
        int index = 0;
        for (String complicationId : complicationSet) {
            complicationIds[index++] = Integer.parseInt(complicationId);
        }
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Job running, updating " + complicationSet);
        }
        providerUpdateRequester.requestUpdate(complicationIds);
    }
    // Schedule the job again to catch the next update to the artwork
    scheduleComplicationUpdateJob(this);
    return false;
}
项目:cordova-plugin-background-fetch    文件:HeadlessJobService.java   
@Override
public boolean onStartJob(final JobParameters params) {

    BackgroundFetch adapter = BackgroundFetch.getInstance(getApplicationContext());

    if (adapter.isMainActivityActive()) {
        return true;
    }

    adapter.registerCompletionHandler(new FetchJobService.CompletionHandler() {
        @Override
        public void finish() {
            Log.d(BackgroundFetch.TAG, "HeadlessJobService jobFinished");
            jobFinished(params, false);
        }
    });

    Log.d(BackgroundFetch.TAG, "HeadlessJobService onStartJob");
    new BackgroundFetchHeadlessTask().onFetch(getApplicationContext());
    return true;
}
项目:LaunchEnr    文件:ColorExtractionService.java   
@Override
public boolean onStartJob(final JobParameters jobParameters) {

    mWorkerHandler.post(new Runnable() {
        @Override
        public void run() {
            WallpaperManager wallpaperManager = WallpaperManager.getInstance(
                    ColorExtractionService.this);
            int wallpaperId = ExtractionUtils.getWallpaperId(wallpaperManager);

            ExtractedColors extractedColors = new ExtractedColors();
            if (wallpaperManager.getWallpaperInfo() != null) {
                // We can't extract colors from live wallpapers; always use the default color.
                extractedColors.updateHotseatPalette(null);
            } else {
                // We extract colors for the hotseat and status bar separately,
                // since they only consider part of the wallpaper.
                extractedColors.updateHotseatPalette(getHotseatPalette());

                if (PreferencesState.isLightStatusBarPrefEnabled(getBaseContext())) {
                    extractedColors.updateStatusBarPalette(getStatusBarPalette());
                }
            }

            // Save the extracted colors and wallpaper id to LauncherProvider.
            String colorsString = extractedColors.encodeAsString();
            Bundle extras = new Bundle();
            extras.putInt(LauncherSettings.Settings.EXTRA_WALLPAPER_ID, wallpaperId);
            extras.putString(LauncherSettings.Settings.EXTRA_EXTRACTED_COLORS, colorsString);
            getContentResolver().call(
                    LauncherSettings.Settings.CONTENT_URI,
                    LauncherSettings.Settings.METHOD_SET_EXTRACTED_COLORS_AND_WALLPAPER_ID,
                    null, extras);
            jobFinished(jobParameters, false /* needsReschedule */);
        }
    });
    return true;
}
项目:AndroidKeepLivePractice    文件:ScheduleService.java   
@Override
public boolean onStartJob(JobParameters params) {
    Log.d(TAG, "onStartJob(): params = [" + params + "]");
    Intent intent = new Intent(getApplicationContext(), DaemonService.class);
    startService(intent);
    jobFinished(params, false);
    return false;
}
项目:2017.2-codigo    文件:DownloadJobService.java   
@Override
public boolean onStartJob(JobParameters params) {
    PersistableBundle pb=params.getExtras();
    if (pb.getBoolean(JobSchedulerActivity.KEY_DOWNLOAD, false)) {
        Intent downloadService = new Intent (getApplicationContext(),DownloadService.class);
        downloadService.setData(Uri.parse(downloadLink));

        getApplicationContext().startService(downloadService);
        return true;
    }
    return false;
}
项目:Bigbang    文件:JobService.java   
@Override
public boolean onStartJob(JobParameters params) {
    LogUtil.d(TAG,"onStartJob");

    startService(new Intent(JobService.this,BigBangMonitorService.class));
    startService(new Intent(JobService.this,ListenClipboardService.class));
    return false;
}
项目:Bigbang    文件:JobService.java   
@Override
public boolean onStopJob(JobParameters params) {
    LogUtil.d(TAG,"onStopJob");
    startService(new Intent(JobService.this,BigBangMonitorService.class));
    startService(new Intent(JobService.this,ListenClipboardService.class));
    return false;
}
项目:AndroidRepositoryWithOfflineMode    文件:LoginJobService.java   
@Override
public boolean onStartJob(JobParameters job) {
    ParentObject parentObject = LoginDAB.parentObject;
    LoginStore store = LoginFactory.getLoginFactory().getStore(StaticInfo.NETWORK_TYPE, null);
    store.save(parentObject, this.getBaseContext());
    return true;
}
项目:androidtv-sample    文件:SyncJobService.java   
@Override
public boolean onStartJob(JobParameters params) {
    if (DEBUG) {
        Log.d(TAG, "onStartJob(" + params.getJobId() + ")");
    }
    EpgSyncTask epgSyncTask = new EpgSyncTask(params);
    synchronized (mTaskArray) {
        mTaskArray.put(params.getJobId(), epgSyncTask);
    }
    epgSyncTask.execute();
    return true;
}
项目:androidtv-sample    文件:SyncJobService.java   
@Override
public boolean onStopJob(JobParameters params) {
    synchronized (mTaskArray) {
        int jobId = params.getJobId();
        EpgSyncTask epgSyncTask = mTaskArray.get(jobId);
        if (epgSyncTask != null) {
            epgSyncTask.cancel(true);
            mTaskArray.delete(params.getJobId());
        }
    }
    return false;
}
项目:androidtv-sample    文件:SyncJobService.java   
private void finishEpgSync(JobParameters jobParams) {
    if (DEBUG) {
        Log.d(TAG, "taskFinished(" + jobParams.getJobId() + ")");
    }
    mTaskArray.delete(jobParams.getJobId());
    jobFinished(jobParams, false);
    if (jobParams.getJobId() == SyncUtils.REQUEST_SYNC_JOB_ID) {
        Intent intent = new Intent(ACTION_SYNC_STATUS_CHANGED);
        intent.putExtra(
                BUNDLE_KEY_INPUT_ID, jobParams.getExtras().getString(BUNDLE_KEY_INPUT_ID));
        intent.putExtra(SYNC_STATUS, SYNC_FINISHED);
        LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
    }
}
项目:mapbox-events-android    文件:SchedulerFlusherJobService.java   
@Override
public boolean onStartJob(final JobParameters params) {
  Intent intent = new Intent(SCHEDULER_FLUSHER_INTENT);
  intent.putExtra(START_JOB_INTENT_KEY, ON_START_INTENT_EXTRA);
  LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
  return false;
}
项目:mapbox-events-android    文件:SchedulerFlusherJobService.java   
@Override
public boolean onStopJob(final JobParameters params) {
  Intent intent = new Intent(SCHEDULER_FLUSHER_INTENT);
  intent.putExtra(STOP_JOB_INTENT_KEY, ON_ERROR_INTENT_EXTRA);
  LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
  return true;
}
项目:leanback-homescreen-channels    文件:SynchronizeDatabaseJobService.java   
@Override
public boolean onStopJob(JobParameters jobParameters) {
    if (mSynchronizeDatabaseTask != null) {
        mSynchronizeDatabaseTask.cancel(true);
        mSynchronizeDatabaseTask = null;
    }
    return true;
}
项目:leanback-homescreen-channels    文件:AddWatchNextService.java   
@Override
public boolean onStartJob(JobParameters jobParameters) {
    AddWatchNextContinueInBackground newTask = new AddWatchNextContinueInBackground(
            jobParameters);
    newTask.execute();
    return true;
}
项目:leanback-homescreen-channels    文件:DeleteWatchNextService.java   
@Override
public boolean onStartJob(JobParameters jobParameters) {
    DeleteWatchNextContinueInBackground newTask = new DeleteWatchNextContinueInBackground(
            jobParameters);
    newTask.execute();
    return true;
}
项目:VirtualHook    文件:StubJob.java   
@Override
public void stopJob(JobParameters jobParams) throws RemoteException {
    int jobId = jobParams.getJobId();
    synchronized (mJobSessions) {
        JobSession session = mJobSessions.get(jobId);
        if (session != null) {
            session.stopSession();
        }
    }
}
项目:QuickPeriodicJobScheduler    文件:QuickPeriodicJobRunner.java   
/**
 * This method should not be called by the application manually.
 * @param jobParameters The JobParameters are generated by the QuickPeriodicJobScheduler based off the id and interval
 * @return Return true because the job is async
 */
@Override
public boolean onStartJob(final JobParameters jobParameters) {
    // Get the jobId
    int id = jobParameters.getJobId();

    // Find the job in the collection
    QuickPeriodicJob job = getQuickPeriodicJob(id);

    if(job != null) {
        // Schedule job again
        long interval = jobParameters.getExtras().getLong("interval");
        QuickPeriodicJobScheduler qpjs = new QuickPeriodicJobScheduler(this);
        qpjs.start(id, interval);

        // Run the job
        job.getJob().execute(new QuickJobFinishedCallback() {
            @Override
            public void jobFinished() {
                QuickPeriodicJobRunner.this.jobFinished(jobParameters, false);
            }
        });
    }

    // Return if the job is async
    return true;
}
项目:QuickPeriodicJobScheduler    文件:UnitTests.java   
@Test
public void testRunnerReturns() {
    QuickPeriodicJobRunner qpjr = new QuickPeriodicJobRunner();

    JobParameters jp = mock(JobParameters.class);
    doReturn(5).when(jp).getJobId();

    Assert.assertTrue(qpjr.onStartJob(jp));
    Assert.assertTrue(qpjr.onStopJob(jp));
}
项目:DailyStudy    文件:MyJobservice.java   
@Override
    public boolean onStartJob(JobParameters params) {

        if(isNetworkConnected()){
//            new WebDownLoadTask().execute(params);
//            Intent intent = new Intent(Intent.ACTION_VIEW);
//            intent.setData(Uri.parse("http://blog.csdn.net/qq_31726827/article/details/50462025"));
//            intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
//            startActivity(intent);

            NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
            Notification notification = builder
                    .setContentTitle("这是通知标题")
                    .setContentText("这是通知内容")
                    .setWhen(System.currentTimeMillis())
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
                    .build();
            manager.notify(1, notification);
            jobFinished(params,false);
            Log.e(TAG, "success");
            return true;
        }
        Log.e(TAG, "fail");
        return false;
    }
项目:TPlayer    文件:StubJob.java   
@Override
public void stopJob(JobParameters jobParams) throws RemoteException {
    int jobId = jobParams.getJobId();
    synchronized (mJobSessions) {
        JobSession session = mJobSessions.get(jobId);
        if (session != null) {
            session.stopSession();
        }
    }
}
项目:KeepProcessAlive    文件:JobSchedulerService.java   
@Override
    public boolean onStartJob(JobParameters params) {

        Log.e("MyLog","onStartJob");

        Integer jobId = params.getJobId();

        ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
//        Optional<String> optional = activityManager.getRunningServices(Integer.MAX_VALUE).stream()
//                .map((x) -> x.service.getClassName().toString())
//                .filter(x -> x.equals(jobservie.get(jobId))).findFirst();
//        if (!optional.isPresent()) {
//            System.out.println("begin recover needkeepservice!");
//            Log.e("MyLog", "begin recover needkeepservice!22");
//            startService(new Intent(this, NeedKeepService.class));
//
//        }

        for (ActivityManager.RunningServiceInfo serviceInfo : activityManager.getRunningServices(128)) {
            if (serviceInfo.service.getClassName().equals(jobservie.get(jobId))) {
                return true;
            }
        }


        Log.e("MyLog", "begin recover needkeepservice!");
        startService(new Intent(this, NeedKeepService.class));


        return true;
    }