Check WiFi and GPS isConnected or Not in Android?(在 Android 中检查 WiFi 和 GPS 是否已连接?)
问题描述
我需要在运行时检查手机中的 wifi 是打开还是关闭?
I would need to check the wifi is on or off in the phone at the runtime?
如果未连接,我想显示对话框并直接转到设置/无线控制以由用户启用.
if it is not connected, i want to show dialog and goto directly Setting/Wireless Controls to enable it by user.
它适用于手机的 wifi 和 Gps 状态.怎么做?哪个意图为此唤醒?有什么想法吗?
its for both wifi and Gps staus of the phone. How to do it? which intent to wake for this? Any idea?
推荐答案
可以使用WifiManager 类获取 Wi-Fi 状态.
You can use the WifiManager class to get the state of Wi-Fi.
参见这个 打开 Wi-Fi 设置的问题.这个问题是关于 GPS 状态的.
See this question for opening Wi-Fi settings. And this question for GPS status.
这篇关于在 Android 中检查 WiFi 和 GPS 是否已连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Android 中检查 WiFi 和 GPS 是否已连接?


- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01