Eshaan Eshaan - 25 days ago 11
Android Question

Custom JobIntentService onHandleWork not called

I recently was updating an app that I work on to handle notifications from push using a JobIntentService instead of a regular IntentService because it seems like the correct way to handle this on pre-lollipop devices as well as post. I am enqueueing work as such:

enqueueWork(context, MyJobServiceExtension.class, JOB_ID, work);


This is the manifest declaration:

<service android:name="com.example.MyJobServiceExtension"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true"
tools:node="replace">


I never see any callbacks in onHandleWork or any error logs in my logcat. Has anyone successfully integrated this that could help?

Update: I tested this on an api level 21 device and it worked.. but it doesn't seem to be getting called on my android O pixel XL device.. Any clues as to why?

Update #2: Also I seem to be seeing the intentservice's onCreate be called, but none of the other lifecycle methods (including onHandleWork). Has anyone encountered this either?

Answer Source

I had the same issue after upgrading from IntentService to JobIntentService. Make sure you remove this method from your old implementation:

@Override
public IBinder onBind(Intent intent) {
    return null;
}

For me this solved the problem, and now it works both on pre- and post-Oreo.