WIFI检测--对话框

public static boolean isWifi(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
if (activeNetInfo != null
&& activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
return true;
}
return false;
}

使用:
if (!mIsWifi) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("初次使用会从网络下载大概5MB的图片,确认要下载吗?");
builder.setTitle("注意");
builder.setPositiveButton("是", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mCanGetBitmapFromNetWork = true;
mImageAdapter.notifyDataSetChanged();
}
});
builder.setNegativeButton("否", null);
builder.show();
}
posted @ 2017-05-17 20:44  Calo-missile  阅读(136)  评论(0编辑  收藏  举报