android 判断网络状态
来源:互联网 发布:聊天室程序源码出售 编辑:程序博客网 时间:2024/06/10 20:37
韩梦飞沙 韩亚飞 313134555@qq.com han_meng_fei_sha yue31313
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE" />
private boolean getNetWorkStatus() {
boolean netSataus = false;
ConnectivityManager cwjManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
cwjManager.getActiveNetworkInfo();
if (cwjManager.getActiveNetworkInfo() != null) {
netSataus = cwjManager.getActiveNetworkInfo().isAvailable();
}
if (!netSataus) {
Builder b = new AlertDialog.Builder(this).setTitle("没有可用的网络")
.setMessage("是否对网络进行设置?");
b.setPositiveButton("是", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Intent mIntent = new Intent("/");
ComponentName comp = new ComponentName(
"com.android.settings",
"com.android.settings.WirelessSettings");
mIntent.setComponent(comp);
mIntent.setAction("android.intent.action.VIEW");
startActivityForResult(mIntent,0);
}
}).setNeutralButton("否", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
}).show();
}
return netSataus;
}
- android 判断网络状态
- Android判断网络状态
- Android 判断网络状态
- android 网络状态判断
- Android: 判断网络状态
- android 网络状态判断
- android 判断网络状态
- android判断网络状态
- android判断网络状态
- android 判断网络状态
- android 判断网络状态
- android 网络状态判断
- Android判断网络状态
- android判断网络状态
- android判断网络状态
- Android判断网络状态
- Android - 判断网络状态
- Android判断网络状态
- http工作原理
- Linux运维工程师:面试题整理
- 最全的常用正则表达式
- android 还原短信
- scala样例类
- android 判断网络状态
- 基本排序算法
- android 调节屏幕亮度
- linux下的argv与environ变量
- studio获得sha1 md5 sha256
- JPA
- 照片人脸识别聚类
- CSDN如何转载、修改别人的文章
- GDI_绘图