/* * 判断网络状态 */ private boolean JudgeNetWorkStatus() { boolean netStatus = false; ConnectivityManager conManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); conManager.getActiveNetworkInfo(); if (conManager.getActiveNetworkInfo() != null) { netStatus = conManager.getActiveNetworkInfo().isAvailable(); } if (!netStatus) { Builder b = new AlertDialog.Builder(this). setTitle(R.string.no_Network_found). setMessage(R.string.whether_set_network); b.setPositiveButton(android.R.string.ok, 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(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).show(); } return netStatus; }