如何在不离开应用程序的情况下在 Android 应用程序中激活网络
我正在开发一个使用 GPS 和地理位置的应用程序。因此,在应用程序启动期间,我必须确保用户已激活网络和 GPS。如果他没有测试两种解决方案:
要求用户自己激活它们(因此应用程序退出,用户必须重新加载它)
在相应的视图中重定向用户以激活它们(通过类似“ android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS ”)
第二种解决方案在我看来更好,但如果用户必须激活网络+ GPS +网络定位,那么对用户来说可能会很无聊......
那就是为什么我问如果不可能的话,是否可以自动激活所有这些?我认为这是可能的,因为它存在小部件,可以让用户激活网络、GPS 等...但是我们如何在应用程序中做到这一点???
感谢您的阅读;)
I am developing an application that use the GPS and the geolocalion. So, during the application launch, I have to be sure that the user has activated the network and GPS. If he didn't tested 2 solutions :
Ask the user to activate them himself (so the application quit, and the user has to reload it)
Redirect the user in the corresponding view in order to activate them ( via something like " android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS " )
The second solution is better to my mind but can be very boring for the user if he has to activate the Network + the GPS + Nework localisation ...
That's why I ask if it is not possible to activate all that automatically if it is not possible ? I think it is possible because it exists widget that let the user activate network, gps etc... but how can we do that in the application ???
thanks for reading ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 Lie Rayn 在对你的问题的评论中所说。您无法直接通过代码激活 GPS。但我认为这篇博文就是你的意思寻找。
您可以启动一个活动,然后向用户显示“位置和安全”设置页面,然后可以在其中激活 GPS。
As Lie Rayn says in his comment to your question. You cannot activated GPS directly via code. but I think this blog post it is what you're looking for.
You can start an activity which then shows the user the "Locations and Security" setting page where GPS can then be activated.