I'm trying to setup a JobIntentService and test it using adb.
When I use this command:
adb shell am startservice -a "com.example.package.action.DO_THING"
It produces the error:
Error: Requires permission android.permission.BIND_JOB_SERVICE
My AndroidManifest.xml has the following entry:
<service
android:name=".services.intents.IntentHandlerService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true">
<intent-filter>
<action android:name="com.example.package.action.DO_THING"/>
</intent-filter>
</service>
JobIntentService
, likeJobService
, is only usable from within an app. You cannot have another app talk to those services, nor is there any sort of directPendingIntent
option.(in theory, you might be able to talk to a
JobIntentService
from other apps on Android 4.4 and older, as I'm not certain howandroid:permission="android.permission.BIND_JOB_SERVICE"
will be handled when that permission is undefined, but I wouldn't count on it)For IPC, you will need to use something else. So, for example, if you want a
PendingIntent
to be processed by aJobIntentService
, create a broadcastPendingIntent
with an explicitIntent
pointing to a manifest-registered receiver, and have it post the job to theJobIntentService
.