我如何在应用程序启动等到WIFI连接? [英] How do I wait during application startup until WIFI connects?

查看:116
本文介绍了我如何在应用程序启动等到WIFI连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像许多应用我的应用程序依赖于WIFI和HTTP连接工作。我所不明确的是,直到WIFI已启用,并且设备连接到WIFI网络是我能怎么时间等待。什么是在应用程序启动延迟足够长的时间才能做到这一点的最好方法是什么?在此期间,我会如保持按钮无效。也就是有什么办法可以使设备尝试连接到它的preferred网络?谢谢

Like many apps my app depends on WIFI and Http Connection to operate. What I am not clear on is how I can time a wait until WIFI is enabled AND device is attached to WIFI network is. What is the best way to delay on application startup long enough for this to happen? during this time I would for example keep buttons deactivated. Also is there any way to make the device attempt to connect to its preferred network? Thanks

推荐答案

使用的 WifiManager 来获取连接的状态。

Use WifiManager to get the state of the connection.

一般来说,你将不得不尝试。 WiFi连接可以显示为连接,但无法实际发送/接收,因为信号太弱。一旦连接到了,应用程序应该尝试连接,只有当它成功,按钮应该被激活等等。

Generally you will have to try. A Wifi connection can show as connected but not be able to actually send/receive because the signal is too weak. Once the connection is up, the app should try connecting and only when it succeeds, the buttons should be activated and so forth.

这篇关于我如何在应用程序启动等到WIFI连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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