大佬教程收集整理的这篇文章主要介绍了android – 要求用户打开Wi-Fi,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当我需要访问某个位置时,我这样做:
final AlertDialog.builder builder = new AlertDialog.builder( MapScreen.this); builder.settitle("MyAppName"); builder.setmessage("The LOCATIOn service is off. Do you want to turn it on?"); builder.setPositiveButton("Enable LOCATIOn",new DialogInterface.onClickListener() { @Override public void onClick( final DialogInterface dialogInterface,final int i) { startActivity(new Intent( android.provider.SetTings.ACTION_LOCATION_sourcE_SETTinGS)); } }); builder.setNegativeButton("ConTinue without LOCATIOn",null); builder.create().show();
然而,GPS给了我一些不够精确的信息. Wi-Fi总是给我足够的准确性,所以我想要求用户打开Wi-Fi,就像我要求他们打开位置一样.我不想只是打开它,我希望用户得到通知,并手动启用它.
startActivity(new Intent(SetTings.ACTION_WIRELESS_SETTinGS));
有关设置的完整列表:https://developer.android.com/reference/android/provider/Settings.html
有关startActivity方法的文档:
https://developer.android.com/reference/android/app/Activity.html#startActivity(android.content.Intent)
(请记住,startActivity只是扔掉而忘记,如果你想捕获用户所做的响应,你可以调用startActivityForResult,在这种情况下可能不需要)
以上是大佬教程为你收集整理的android – 要求用户打开Wi-Fi全部内容,希望文章能够帮你解决android – 要求用户打开Wi-Fi所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。