等待 Android 上的 wifi 连接
我有一个小程序尝试连接到 wifi 网络。 如果这是第一次连接到某些网络,它会启用设备上的 wifi。它会加载设备 wifi,以便选择并添加连接密码。 在我添加密码以便连接之前,程序应该不会完成。 如何添加一些内容以等待我从已连接的 wifi 管理器获取信息? 我尝试睡眠,但它冻结了应用程序并且无法连接 wifi 弹出菜单? 还有其他方法吗?
I have a small program that trying to connect to a wifi network.
It enables the wifi on the device then if it's the first time that is connect to the certain networkss It loads the device wifi in order to select and add the password for connection.
Until I add the password in order to connect the program should not be finished.
How can I add something to wait until I get from the wifi manager that is connected?
I try sleep but it freeze the application and am not getting the wifi pop up menu to connect?
are there any other ways?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一个月前已经找到了您问题的解决方案,只需使用 Thread put 方法 isConnected() 即可。
在本例中,我使用 WifiExplorerActivity 来显示所有 wifi 网络并允许用户连接到它。
这是检查 wifi 是否已连接的功能:
最后,确保您的 Androidmanifest.xml 如下所示:
另外,您可以使用 ProgressDialog 来等待连接。请参阅http://developer.android.com/guide/topics/ui/dialogs。 html
I have found the solution for your problem a month ago, just use Thread put method isConnected() in it.
In this case, I use WifiExplorerActivity to display all wifi network and allow user connect to it.
And this is function to check wifi has connected or not:
Finally, make sure your Androidmanifest.xml look like this:
Also, you can use ProgressDialog to wait connect. See http://developer.android.com/guide/topics/ui/dialogs.html