标签:mystra android runonuithread getactivity bug
Bug: runOnUiThread
本文地址: http://blog.csdn.net/caroline_wendy
Bug:
java.lang.NullPointerException: Attempt to invoke virtual method ‘void android.support.v4.app.FragmentActivity.runOnUiThread(java.lang.Runnable)‘ on a null object reference
at me.chunyu.ChunyuDoctor.Modules.DoctorService.h.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
原因:
I‘m almost sure that this is caused when the thread finish its work but the activity is no longer visible.
You should check if the "getActivity()" call return null, and ...
getActivity()有可能为空,需要提前判断;
位置:DocServiceBannerFragment;
if (getActivity() == null)
return;
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
_updateBanners(bannerItems, bannerImages);
}
});
即可,完成。
Android - Bug: runOnUiThread
标签:mystra android runonuithread getactivity bug
原文地址:http://blog.csdn.net/caroline_wendy/article/details/42671855