I'm facing a weird issue. My code has a broadcast-receiver, which does this in its onReceive():
view.post(new Runnable() {
@Override
public void run() {
view.refreshUI();
}});
I'm confused about the reason for this code to present the android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
I'm already posting the refreshUI()
call inside Runnable
onto view
. So how does it not run on the UI-thread?
Another weird observation is that the broadcast-sending service hasn't even sent the broadcast in the case where I see this crash. I know this because there are statements logged to the logcat on both the sender & receiver side. But one of this are present before the crash.
To give some background, the above code is written inside the Android framework, for the keyguard (OR lock-screen). I'm working on Android 4.3 source-code which is customized for our hardware/board.
The above code is present as it is since last 1.5 years. The issue has been seen only twice in the last few months though nothing has been changed here.
I've already gone through Running on UIThread and posting to view, still get CalledFromWrongThreadException & other similar questions, but they are mostly dealing with AsyncTasks
. I do not have any AsyncTask
in my case.
Any thoughts?