本文主要是介绍Android AlertDialog 提示设置网络,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/*** 提示设置网络*/
public void setNetwork() {AlertDialog.Builder dialog = new Builder(context);dialog.setTitle("提示信息").setMessage("网络未连接,设置网络连接?");dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int which) {Intent i = null;if (android.os.Build.VERSION.SDK_INT > 10) {i = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);} else {i = new Intent();ComponentName name = new ComponentName("com.android.settings","com.android.settings.WirelessSettings");i.setComponent(name);i.setAction("android.intent.action.VIEW");}// Intent i = new Intent(android.settings.WIRELESS_SETTINGS);startActivity(i);}});dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {public void onClick(DialogInterface dialog, int which) {dialog.dismiss();}}).show();
}
这篇关于Android AlertDialog 提示设置网络的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!