3

我有一个 JobIntentService,它根本没有做很多工作,但今天导致了 ANR。

通过以下方式从伴随对象调用代码有什么问题吗?

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)
        }
    }
}

根据文档,没有任何内容onHandleWork()导致 ANR,因为该方法是从单独的线程调用的。

工作通过伴随对象排队的方式是否存在会导致 ANR 的问题?注入代码是标准的 Dagger2 依赖注入,我从来没有遇到过问题。

ANR 看起来像这样

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

4

0 回答 0