//显示对话框设置网络
private void showNetWorkDialog() {
AlertDialog.Builder builder=new Builder(this);
builder.setTitle(R.string.NetWorkDialogTitle);
builder.setMessage(R.string.NetWorkDialogMessage);
//设置网络
builder.setPositiveButton(R.string.NetWorkDialogPositiveButton, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent =null;
//判断手机系统的版本 3.0或以上版本
if(android.os.Build.VERSION.SDK_INT>10){
intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
}else{
intent = new Intent();
//后面一定要带包名
ComponentName component = new ComponentName("com.android.settings","com.android.settings.WirelessSettings");
intent.setComponent(component);
intent.setAction("android.intent.action.VIEW");
}
startActivity(intent);
finish();
}
});
//取消
builder.setNegativeButton(R.string.NetWorkDialogNegativeButton, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
//显示
builder.create().show();
}
Android 访问网络连接设置界面
最新推荐文章于 2024-05-07 19:54:46 发布