Error in Logcat
下面是我的网络连接代码,我得到" Wifi_P2p_StateTracker"错误,如何解决此错误,在AndroidManifest文件中我已声明所有权限。
public class ConnectionDetector {
private Context context;
public ConnectionDetector(Context context) {
this.context = context;
}
public boolean isConnected() {
boolean wifiDataAvailable = false;
boolean mobileDataAvailable = false;
try {
ConnectivityManager conManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] networkInfo = conManager.getAllNetworkInfo();
for (NetworkInfo netInfo : networkInfo) {
if (netInfo.getTypeName().equalsIgnoreCase("WIFI"))
if (netInfo.isConnected())
wifiDataAvailable = true;
if (netInfo.getTypeName().equalsIgnoreCase("MOBILE"))
if (netInfo.isConnected())
mobileDataAvailable = true;
}
} catch (Exception e) {
e.printStackTrace();
}
return wifiDataAvailable || mobileDataAvailable;
}
}