Android 无网路弹出对话框
if (isConnect(this) == false) {
Toast.makeText(MainActivity.this, "設備無連接,請鏈接到網絡", 2000).show();
}
else {
Toast.makeText(MainActivity.this, "鏈接到球赛比分網絡", 1000).show();
}
private boolean isConnect(
MainActivity mainActivity) {
ConnectivityManager conManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = conManager
.getActiveNetworkInfo();
if (networkInfo != null) { // 注意,这个判断一定要的哦,要不然会出错
return networkInfo
.isAvailable();
}
return false;
补充:移动开发 , Android ,