在 Android 中检查 WiFi 和 GPS 是否已连接? [英] Check WiFi and GPS isConnected or Not in Android?

查看:16
本文介绍了在 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 是否已连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆