当前位置: 首页>>代码示例>>Java>>正文


Java JobParameters.getJobId方法代码示例

本文整理汇总了Java中android.app.job.JobParameters.getJobId方法的典型用法代码示例。如果您正苦于以下问题:Java JobParameters.getJobId方法的具体用法?Java JobParameters.getJobId怎么用?Java JobParameters.getJobId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.job.JobParameters的用法示例。


在下文中一共展示了JobParameters.getJobId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onStartJob

import android.app.job.JobParameters; //导入方法依赖的package包/类
@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;
}
 
开发者ID:apsun,项目名称:QuoteLock,代码行数:19,代码来源:QuoteDownloaderService.java

示例2: onStartJob

import android.app.job.JobParameters; //导入方法依赖的package包/类
@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;
}
 
开发者ID:M66B,项目名称:BackPackTrackII,代码行数:20,代码来源:JobExecutionService.java

示例3: onStopJob

import android.app.job.JobParameters; //导入方法依赖的package包/类
@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;
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:13,代码来源:SyncJobService.java

示例4: finishEpgSync

import android.app.job.JobParameters; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:15,代码来源:SyncJobService.java

示例5: stopJob

import android.app.job.JobParameters; //导入方法依赖的package包/类
@Override
public void stopJob(JobParameters jobParams) throws RemoteException {
    int jobId = jobParams.getJobId();
    synchronized (mJobSessions) {
        JobSession session = mJobSessions.get(jobId);
        if (session != null) {
            session.stopSession();
        }
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:11,代码来源:StubJob.java

示例6: onStartJob

import android.app.job.JobParameters; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:simplymadeapps,项目名称:QuickPeriodicJobScheduler,代码行数:32,代码来源:QuickPeriodicJobRunner.java

示例7: onStartJob

import android.app.job.JobParameters; //导入方法依赖的package包/类
@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;
    }
 
开发者ID:XaskYSab,项目名称:KeepProcessAlive,代码行数:32,代码来源:JobSchedulerService.java

示例8: onStartJob

import android.app.job.JobParameters; //导入方法依赖的package包/类
@Override
public boolean onStartJob(JobParameters params) {
    int connectivityScheduleId = getScheduleId(this, ON_NETWORK_AVAILABLE_JOB_ID);
    if (params.getJobId() == connectivityScheduleId) {
        MobileMessagingLogger.d(TAG, "Network available");
        mobileMessagingCore().retrySync();
        return false;
    }

    return false;
}
 
开发者ID:infobip,项目名称:mobile-messaging-sdk-android,代码行数:12,代码来源:MobileMessagingJobService.java

示例9: onStopJob

import android.app.job.JobParameters; //导入方法依赖的package包/类
@Override
public boolean onStopJob(JobParameters params) {
    if (params.getJobId() == PERIODIC_SCAN_JOB_ID) {
        LogManager.i(TAG, "onStopJob called for periodic scan " + this);
    }
    else {
        LogManager.i(TAG, "onStopJob called for immediate scan " + this);
    }
    // Cancel the stop timer.  The OS is stopping prematurely
    mStopHandler.removeCallbacksAndMessages(null);
    stopScanning();
    startPassiveScanIfNeeded();

    return false;
}
 
开发者ID:AltBeacon,项目名称:android-beacon-library,代码行数:16,代码来源:ScanJob.java

示例10: onStartJob

import android.app.job.JobParameters; //导入方法依赖的package包/类
@Override
public boolean onStartJob(final JobParameters params) {
    final int jobId = params.getJobId();
    final JobProxy.Common common = new JobProxy.Common(this, CAT, jobId);

    // don't mark starting!
    final JobRequest request = common.getPendingRequest(true, false);
    if (request == null) {
        return false;
    }

    if (request.isTransient()) {
        if (TransientBundleCompat.startWithTransientBundle(this, request)) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                // should only happen during testing if an API is disabled
                CAT.d("PendingIntent for transient bundle is not null although running on O, using compat mode, request %s", request);
            }
            return false;

        } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
            CAT.d("PendingIntent for transient job %s expired", request);
            return false;
        }
    }

    common.markStarting(request);

    JobConfig.getExecutorService().execute(new Runnable() {
        @Override
        public void run() {
            try {
                common.executeJobRequest(request, getTransientBundle(params));

            } finally {
                // do not reschedule
                jobFinished(params, false);
            }
        }
    });

    // yes, we have a job running in the background
    return true;
}
 
开发者ID:evernote,项目名称:android-job,代码行数:44,代码来源:PlatformJobService.java

示例11: onStartJob

import android.app.job.JobParameters; //导入方法依赖的package包/类
@Override
public boolean onStartJob(final JobParameters jobParameters) {
    initialzeScanHelper();
    if (jobParameters.getJobId() == IMMEDIATE_SCAN_JOB_ID) {
        LogManager.i(TAG, "Running immediate scan job: instance is "+this);
    }
    else {
        LogManager.i(TAG, "Running periodic scan job: instance is "+this);
    }

    List<ScanResult> queuedScanResults = ScanJobScheduler.getInstance().dumpBackgroundScanResultQueue();
    LogManager.d(TAG, "Processing %d queued scan resuilts", queuedScanResults.size());
    for (ScanResult result : queuedScanResults) {
        ScanRecord scanRecord = result.getScanRecord();
        if (scanRecord != null) {
            mScanHelper.processScanResult(result.getDevice(), result.getRssi(), scanRecord.getBytes());
        }
    }
    LogManager.d(TAG, "Done processing queued scan resuilts");

    boolean startedScan;
    if (mInitialized) {
        LogManager.d(TAG, "Scanning already started.  Resetting for current parameters");
        startedScan = restartScanning();
    }
    else {
        startedScan = startScanning();
    }
    mStopHandler.removeCallbacksAndMessages(null);

    if (startedScan) {
        LogManager.i(TAG, "Scan job running for "+mScanState.getScanJobRuntimeMillis()+" millis");
        mStopHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                LogManager.i(TAG, "Scan job runtime expired: " + ScanJob.this);
                stopScanning();
                mScanState.save();
                ScanJob.this.jobFinished(jobParameters , false);

                // need to execute this after the current block or Android stops this job prematurely
                mStopHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        scheduleNextScan();
                    }
                });

            }
        }, mScanState.getScanJobRuntimeMillis());
    }
    else {
        LogManager.i(TAG, "Scanning not started so Scan job is complete.");
        ScanJob.this.jobFinished(jobParameters , false);
    }
    return true;
}
 
开发者ID:AltBeacon,项目名称:android-beacon-library,代码行数:58,代码来源:ScanJob.java


注:本文中的android.app.job.JobParameters.getJobId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。