Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonUtil 获取网络信息空指针异常 #3040

Closed
AinialJing opened this issue Nov 12, 2020 · 3 comments
Closed

CommonUtil 获取网络信息空指针异常 #3040

AinialJing opened this issue Nov 12, 2020 · 3 comments

Comments

@AinialJing
Copy link

问题描述:

CommonUtil 获取网络信息时出现了崩溃,没有判断是否为null

问题机型/系统:

定制平板 android系统9.0

GSY依赖版本

implementation 'com.shuyu:gsyVideoPlayer-java:6.0.3'`

Demo中的复现步骤

Demo中的detailPlayer页面打开后XXXX会出现这个问题。

问题代码:(如果有)

 public static boolean isWifiConnected(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo wifiNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if (wifiNetworkInfo.isConnected()) {
            return true;
        }
        return false;
    }

问题log(如果有)


java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.net.NetworkInfo.isConnected()' on a null object reference
        at com.shuyu.gsyvideoplayer.utils.CommonUtil.isWifiConnected(CommonUtil.java:51)
        at com.shuyu.gsyvideoplayer.video.base.GSYVideoControlView.isShowNetConfirm(GSYVideoControlView.java:1045)
        at com.shuyu.gsyvideoplayer.video.base.GSYVideoControlView.clickStartIcon(GSYVideoControlView.java:824)
        at com.shuyu.gsyvideoplayer.video.base.GSYVideoControlView.onClick(GSYVideoControlView.java:382)
        at android.view.View.performClick(View.java:6608)

@CarGuo
Copy link
Owner

CarGuo commented Nov 12, 2020

定制平板我也没条件浮现呀~~获取不到 NetworkInfo 我觉得不是库的问题 ,是平板定制有问题····

@CarGuo CarGuo closed this as completed Nov 12, 2020
@AinialJing
Copy link
Author

加个非空的判断吧!至少不让程序崩溃

@CarGuo
Copy link
Owner

CarGuo commented Nov 12, 2020

这个可以有,问题是也不会那么快发布下一个版本呀~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants