如何以编程方式知道设备已连接到 Wifi 或 3G [英] How to know device is connected to Wifi or 3G, programatically

查看:16
本文介绍了如何以编程方式知道设备已连接到 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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