Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JobService does not require android.permission.BIND_JOB_SERVICE permission

I am getting does not require android.permission.BIND_JOB_SERVICE permission error while scheduling my JobService and I already have the bind permissions. Below is my code.

JobScheduler jobScheduler = (JobScheduler) getSystemService(JOB_SCHEDULER_SERVICE);
ComponentName componentName = new ComponentName(MainActivity.this,MyJobService.class);
JobInfo.Builder jobInfo = new JobInfo.Builder(101, componentName).setPeriodic(2000);
jobScheduler.schedule(jobInfo.build())

 <service
  android:name=".MyJobService"
  android:permission="android:permission.BIND_JOB_SERVICE"
  android:exported="true"/>

Error:

java.lang.IllegalArgumentException: Scheduled service ComponentInfo{services.acadglid.com.acadgildservices/services.com.es.MyJobService} does not require android.permission.BIND_JOB_SERVICE permission

like image 365
Akhilesh Mani Avatar asked Nov 16 '17 09:11

Akhilesh Mani


2 Answers

To solve this problem:

Scheduled service ComponentInfo{.........} does not require android.permission.BIND_JOB_SERVICE permission

add the permission:

        android:permission="android.permission.BIND_JOB_SERVICE"

but requires the property:

android:exported="..."

android:exported: Whether or not the broadcast receiver can receive messages from sources outside its application — "true" if it can, and "false" if not.

For example:

    <service android:name="com.jorgesys.jobscheduler.MyService"
        android:permission="android.permission.BIND_JOB_SERVICE"
        android:exported="true"/>
like image 176
Jorgesys Avatar answered Nov 19 '22 04:11

Jorgesys


There's a typo in your Android Manifest.

Just change the following line:

android:permission="android:permission.BIND_JOB_SERVICE"
                           ^
                           |
                    This " : " is WRONG!

to

android:permission="android.permission.BIND_JOB_SERVICE"

So just change : (colon) in to . (dot).

like image 11
Constanza Quaglia Avatar answered Nov 19 '22 04:11

Constanza Quaglia