A
A
Anton Akimov2017-04-25 12:55:08
Android
Anton Akimov, 2017-04-25 12:55:08

JobScheduler. Why won't the JobService start?

I'm trying to start JobScheduler, but for some reason my JobService is not even created. The application does not crash, there are no errors, but the service does not start. Please take a look, maybe I missed something?
Code for creating/starting the Scheduler:

JobScheduler jobScheduler = (JobScheduler) appContext.getSystemService(Context.JOB_SCHEDULER_SERVICE);
        jobScheduler.schedule(new JobInfo.Builder(1, new ComponentName(appContext, SchedulerService.class))
                .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
                .build());

Service code:
public class SchedulerService extends JobService {

    private static final String LOG_TAG = "SchedulerService";

    @Override
    public void onCreate() {
        Log.d(LOG_TAG, "onCreate");
        super.onCreate();
    }

    @Override
    public boolean onStartJob(JobParameters params) {
        Log.d(LOG_TAG, "onStartJob");
        return true;
    }

In the manifest, the service is declared:
<service
            android:name=".SchedulerService"
            android:permission="android.permission.BIND_JOB_SERVICE"/>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Akimov, 2017-04-25
@antaki93

Here is the madness. The problem was solved by cleaning the project caches (File > Invalidate Caches) and restarting the smartphone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question