[英]Android: How to show wifi setting in pop up window
I have following code, which bring my app to the background and bring out the WIFI setting 我有以下代码,这些代码使我的应用程序进入后台并显示WIFI设置
startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
Is it possible to have the WIFI setting shown up in a alert dialog so it doesn't leave my app? 是否可以在警报对话框中显示WIFI设置,这样它就不会离开我的应用程序?
Thanks. 谢谢。
Create dialog like this : 创建这样的对话框:
final WifiManager mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle("Wifi Settings");
// set dialog message
alertDialogBuilder
.setMessage("Do you want to enable WIFI ?")
.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
//enable wifi
wifiMan.setWifiEnabled(true);
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
//disable wifi
wifiMan.setWifiEnabled(false);
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
Hope it will Help you 希望对你有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.