How to know device is connected to Wifi or 3G, programatically(如何以编程方式知道设备已连接到 Wifi 或 3G)
问题描述
我如何知道设备是否以编程方式连接到 Wifi 或 3G
How i can know device is connected to Wifi or 3G, programmatically
谢谢
推荐答案
你可以使用上面提到的 WifiManager 类 这里
you can use WifiManager class as mentioned here
通过调用 WifiManager 类的 getConnectionInfo() 函数,您将获得 WifiInfo 对象
by calling getConnectionInfo() function of WifiManager class you will get WifiInfo object
WifiInfo 具有 getBSSID() 函数,可以为您提供连接的 AP 名称
WifiInfo has function getBSSID() which gives you connected AP's name
如果它为空,则表示它没有通过 Wifi 连接到任何 AP(未启用 Wifi)
if its null that means it is not connected to any AP via Wifi ( Wifi is not enabled )
顺便说一句,在寻找更多信息时,我发现 this 应该回答您关于移动连接和 wifi 连接的所有问题
btw while looking for more info, i found this which should answer all your questions about mobile connectivity and wifi connectivity
这篇关于如何以编程方式知道设备已连接到 Wifi 或 3G的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何以编程方式知道设备已连接到 Wifi 或 3G


基础教程推荐
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01