在 oppo f1 版本 5.1 中运行应用程序时,logcat 显示以下错误:
ANR_LOG: >>> msg's executing time is too long
Blocked msg = { when=-15s421ms what=0 target=android.view.Choreographer$FrameHandler callback=android.view.Choreographer$FrameDisplayEventReceiver } , cost = 15162 ms
>>>Current msg List is:
Current msg <1> = { when=-15s412ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <2> = { when=-15s410ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <3> = { when=-15s408ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <4> = { when=-15s405ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <5> = { when=-15s403ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <6> = { when=-15s400ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <7> = { when=-15s398ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <8> = { when=-15s395ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <9> = { when=-15s393ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <10> = { when=-15s386ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <11> = { when=-15s383ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <12> = { when=-15s377ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <13> = { when=-15s374ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <14> = { when=-15s367ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <15> = { when=-15s359ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <16> = { when=-15s350ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <17> = { when=-15s346ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <18> = { when=-15s339ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <19> = { when=-15s336ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
Current msg <20> = { when=-15s333ms what=0 target=android.os.Handler callback=android.support.v4.content.res.ResourcesCompat$FontCallback$2 }
>>>CURRENT MSG DUMP OVER<<<
07-19 16:36:51.656 12279-12279/com.symphonyfintech.xts E/ANR_LOG: >>> msg's executing time is too long
Blocked msg = { when=-4s18ms what=0 target=android.view.Choreographer$FrameHandler callback=android.view.Choreographer$FrameDisplayEventReceiver } , cost = 3789 ms
>>>Current msg List is:
Current msg <1> = { when=-3s315ms what=0 target=android.widget.Editor$Blink callback=android.widget.Editor$Blink }
>>>CURRENT MSG DUMP OVER<<<
最佳答案
作为引用,请在下面找到代码 fragment :
val mainHandler = Handler(getMainLooper())
var runnable: Runnable = object : Runnable {
override fun run() {
//Do your work here !!
}
}
mainHandler.postDelayed(runnable, //delay)
关于android - 在 Oppo F1 中的 Handler 的 postDelayed() 延迟结束后,Runnable 并未完全执行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51435390/