视频加载失败

Android: runOnUiThread

50 字
1 分钟
Android: runOnUiThread
Android: runOnUiThread

在Fragment中使用getActivity().runOnUiThread()更新Ui可能会遇到报错:

java.lang.NullPointerException: Attempt to invoke virtual method ‘void android.support.v4.app.FragmentActivity.runOnUiThread(java.lang.Runnable)’ on a null object reference at com.rehtt.app.Fragment.MainFragment$3.onFailure(MainFragment.java<103>)

这是因为getActivity()为null所致。

解决方法:

if (getActivity() !=null ){
getActivity().runOnUiThread(......);
}

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!

打赏
Android: runOnUiThread
https://rehtt.com/posts/30/
作者
Rehtt
发布于
2018-03-14
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
Rehtt
Hello, I'm Rehtt.
公告
欢迎来到我的博客!
分类
标签
最新动态
站点统计
文章
150
分类
17
标签
73
总字数
67,772
运行时长
0 天
最后活动
0 天前
站点信息
构建平台
Local
博客版本
Firefly v6.16.8
文章许可
CC BY-NC-SA 4.0

当前页面没有目录

文章目录

当前页面没有目录