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


基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01