** |
* 判断网络状态 |
* |
* @return |
*/ |
public boolean isNetworkConnected() { |
if (context != null ) { |
ConnectivityManager mConnectivityManager = (ConnectivityManager) context |
.getSystemService(Context.CONNECTIVITY_SERVICE); |
NetworkInfo mNetworkInfo = mConnectivityManager |
.getActiveNetworkInfo(); |
if (mNetworkInfo != null ) { |
return mNetworkInfo.isAvailable(); |
} |
} |
return false ; |
} |
<uses-permission android:name= "android.permission.INTERNET" /> |
初级程序员
by: 云代码会员 发表于:2017-06-04 15:21:39 顶(0) | 踩(0) 回复
谢谢
回复评论