标签:
1、清单文件
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
2、代码
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
ConnectivityManager cm =(ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getActiveNetworkInfo();
if(info != null && info.isConnected()){
Toast.makeText(this, "网络链接成功", 0).show();
}else{
Toast.makeText(this, "网络链接失败", 0).show();
}
}
标签:
原文地址:http://www.cnblogs.com/zhongyinghe/p/5384768.html