我已经在 Play 商店中发布了我的应用程序,我正在使用以下方法检查网络状态:
public class TestInternetConnection {
public boolean checkInternetConnection(Context context) {
ConnectivityManager con_manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (con_manager.getActiveNetworkInfo() != null && con_manager.getActiveNetworkInfo().isAvailable() && con_manager.getActiveNetworkInfo().isConnected()) {
return true;
} else {
return false;
}
}
}
在Google Play 控制台中,我看到三星设备在checkInternetConnection
使用Nullpointerexception
. 问题是什么?在我的设备和其他设备上它工作得很好。
堆栈跟踪:
java.lang.NullPointerException:
at de.name.app.TestInternetConnection.checkInternetConnection (TestInternetConnection.java)
at de.name.app.SubstitutionInfoFragment$2.run (SubstitutionInfoFragment.java)
at java.lang.Thread.run (Thread.java:762)