public boolean CheckNetwork() {
boolean flag = false;
ConnectivityManager cwjManager = (ConnectivityManager) AndroidBaseActivity.self.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cwjManager.getActiveNetworkInfo() != null)
flag = cwjManager.getActiveNetworkInfo().isAvailable();
if (!flag) {
Builder b = new AlertDialog.Builder( AndroidBaseActivity.self).setTitle("没有可用的网络").setMessage( AndroidBaseActivity.self.getResources().getString(R.string.net_work_message));
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");
AndroidBaseActivity.self.startActivity(mIntent);
}
}).setNeutralButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
}).create();
b.show();
}
Toast.makeText(AndroidBaseActivity.self, "test", 1).show();
return flag;
}