Reputation: 31
My app needs to do something periodically so I'm trying the Job Scheduler introduced in Android API 21. At this moment I'm just gettingto know it and try the basics. Unfortunately I get an error:
Java.lang.illegalArgumentException: No such service ComponentInfo{The whole path here to the service class name TestJobService}
I understand this has been solved for some by adding permission to Manifest, but not me. What else can cause this?
This is my code part where I guess it goes wrong:
Toast.makeText(getApplicationContext(), "Exec reaches here...",Toast.LENGTH_SHORT).show();
JobInfo.Builder builder = new JobInfo.Builder(1, new ComponentName(getPackageName(),TestJobService.class.getName()));
//runs job service after every 10 seconds
builder.setPeriodic(10000);
jobScheduler.schedule(builder.build());
I have this in my Manifest:
<service
android:name=".TestJobService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true" >
</service>
One thing that confuses me is that I cant manually give job-permission to the app manually in the device settings (I do that to get permission to storage). If the app needs permission for schedualing jobs, shouldn't I have to give permission in the settings?
I really hope someone has the solution for this.
Thanks.
Upvotes: 1
Views: 2018
Reputation: 272
add <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
to the user permissions in the manifest. it did it for me.
Upvotes: 0
Reputation: 31
Make sure you put your service element inside application element and nowhere else. When I did it worked fine.
Upvotes: 2