在我的应用程序中,在进入应用程序之前,我必须检查我的 wifi 连接,如果未启用 wifi,则将用户带到 wifi 设置。
我不想使用WifiManager.setWifiEnabled();
,因为我想给用户设置它的机会。
我已经提到了链接,onActivityResult() 过早地调用
但这对我不起作用。OnActivityResult()
和onResume()
几乎在我进入设置菜单的同时被调用。
这是我的代码,
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setMessage("You are not currently connected to any network. Please turn on the network connection to continue.")
alert.setPositiveButton("Settings", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int arg1)
{
Intent intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
startActivityForResult(intent,SETTINGSCODE);
dialog.cancel();
}
});
alert.show();
在 onActivityResult() 中,我再次检查了在更改设置之前调用的网络状态。
我该怎么做 OnActivityResult()
只有从settings menu
?
请帮我解决这个问题..!!