3

I have a JobIntentService that is not doing a lot of work at all, but caused an ANR today.

Is there anything wrong with calling code from the companion object in the following way?

class MyIntentService : JobIntentService() {

    @Inject
    lateinit var myObject: MyObject

    override fun onCreate() {
        super.onCreate()
        MyApplication.appComponent(this).inject(this)
    }

    override fun onHandleWork(intent: Intent) {
        //doing work on a separate thread
    }

    companion object {
        fun enqueueMyWork(context: Context, intent: Intent) {
            enqueueWork(context, MyIntentService::class.java, JOB_ID, intent)
        }
    }
}

There isn't anything in onHandleWork() that is causing the ANR because the method is invoked from a separate thread, per the documentation.

Is there a problem with the way that work is being enqueued through the companion object that would cause an ANR? The injection code is standard Dagger2 dependency injection that I've never had a problem with.

The ANR looks like this

12-03 13:29:42.272 872-872/? I//system/bin/tombstoned: intercept for pid 29905 and type kDebuggerdNativeBacktrace terminated: due to input

Tyler
  • 19,113
  • 19
  • 94
  • 151

0 Answers0