Android应用程序:GOT Internet连接 [英] Android Application: Got Internet Connection

查看:149
本文介绍了Android应用程序:GOT Internet连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能得到检查一个成功的互联网连接(WIFI / 3G /任何其他人)我已经显示错误给用户,如果他们不具备Wifi连接,但我如何才能确保随后该用户就得到了3G连接如果他们希望连接使用的应用程序没有Wifi连接?

How can I check got a successful internet connect (Wifi/3G/whatever else) I already display an error to the user if they don't have Wifi connection but how can I make sure then that the user does got 3G connection if they wish to connect to use the application without the Wifi connection?

推荐答案

如果你只是想看看手机连接到网络,你可以尝试: ConnectivityManager.getAllNetworkInfo(),然后为每个网络适配器检查 networkinfo.getState()。这应该告诉你,无论是连接与否。不过,我不知道是否有一种方法可以专门针对3G检查。

If you just want to see if the phone is connected to the network, you could try: ConnectivityManager.getAllNetworkInfo() and then for each network adapter check networkinfo.getState(). That should tell you whether it's connected or not. However, I'm not sure if there's a way to specifically check for 3G.

这篇关于Android应用程序:GOT Internet连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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