如何知道装置被连接到无线或3G,编程 [英] How to know device is connected to Wifi or 3G, programatically

查看:116
本文介绍了如何知道装置被连接到无线或3G,编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能怎么知道设备连接到WiFi或3G,编程

How i can know device is connected to Wifi or 3G, programmatically

感谢

推荐答案

您可以使用WifiManager类提到的<一个href="http://stackoverflow.com/questions/2973290/check-wifi-and-gps-isconnected-or-not-in-android/2973334#2973334">here

you can use WifiManager class as mentioned here

编辑: 通过调用getConnectionInfo()WifiManager类的功能,你会得到 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

如果其为null,这意味着它没有连接到通过Wifi任何AP(无线未启用)

if its null that means it is not connected to any AP via Wifi ( Wifi is not enabled )

顺便说一句,同时寻找更多的信息,我发现应该回答所有你对移动连接和WiFi连接问题

btw while looking for more info, i found this which should answer all your questions about mobile connectivity and wifi connectivity

这篇关于如何知道装置被连接到无线或3G,编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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