如何连接到Android中使用意向已知的WiFi无线? [英] How to connect to known WiFI using Intent in Android?

查看:160
本文介绍了如何连接到Android中使用意向已知的WiFi无线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的事情:

wifiNetworks = (ArrayList<ScanResult>) mWifiManager.getScanResults();

现在,我可以简单地得到的WiFi SSID:

Now I can simply get wifi SSID:

wifiNetworks.get(0).SSID

我不知道网络是WEP,WPA,它有密码或没有,所以我只是想创建一个Intent,放在那里SSID或ScanResult,它为了让用户输入发送到设置或其它地方密码并连接到该网络。可能吗?如果没有,拿什么来获取有关网络类型的信息和编程连接到它的最简单的方法是什么?

I don't know if network is WEP, WPA, does it have password or not, so I just want to create an Intent, put there SSID or ScanResult and send it to Settings or wherever in order to let user to enter the password and connect to that network. Is it possible? And if not, what is the easiest way to get information about network type and connect programatically to it?

推荐答案

签出此链接:<一href="http://stackoverflow.com/questions/8818290/how-to-connect-to-a-specific-wifi-network-in-android-programmatically">How连接到特定的无线网络中的机器人编程?。

ScanResult有您需要了解有关网络的一切。

ScanResult has everything you need to know about the network.

wifiNetworks.get(0).capabilities

给出的字符串。

gives a string.

capabilities format = [security-key-group cipher]<[security]>

只需使用这3个值分开 - 作为分隔符,并获得安全

Just separate these 3 values using "-" as separator and get the security.

security can have the following values:

OPEN
WEP
WPA
WPA2    

如果安全=WEP,则密钥和组密码都为空。

If security = "WEP" then key and group cipher are null.

这篇关于如何连接到Android中使用意向已知的WiFi无线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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