Android判断是否有网络连接,如果没有开启移
1个回答
展开全部
public static boolean isNetworkConnected() {
ConnectivityManager mConnectivityManager = (ConnectivityManager) MyApplication.getInstance()
.getSystemService(Context.CONNECTIVITY_SERVICE);
assert mConnectivityManager != null;
NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
return mNetworkInfo != null;
}
请给分!!
ConnectivityManager mConnectivityManager = (ConnectivityManager) MyApplication.getInstance()
.getSystemService(Context.CONNECTIVITY_SERVICE);
assert mConnectivityManager != null;
NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
return mNetworkInfo != null;
}
请给分!!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询