How to get scanned wifi networks security type? And what is the network configuration required to connect to particular network using WiFi in android?

StackOverflow https://stackoverflow.com/questions/21704431

質問

I am new to android development & I am trying to create an app which connects to available wifi network for data communication. There are various security types for wifi network configuration.(EX WEP, etc). How to know which network is using which security type? & after knowing that, how to connect to particular network.

I've searched a lot for my problem, & found this:

  1. WEP Network requires:

    wifiConfigObj.wepKeys[0] = "\"" + networkPass + "\"";
    wifiConfigObj.wepTxKeyIndex = 0;
    wifiConfigObj.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
    wifiConfigObj.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
    
  2. EAP Network requires:

     wifiConfigObj.preSharedKey = "\""+ networkPass +"\"";
    
  3. Public Network requires

     wifiConfigObj.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
    

But still I am unable to get any clarity. Please Let me know how to get through it. Thanks..

役に立ちましたか?

解決

See answer given by ayj in this question.

In case link doesn't work in future, let me copy paste it for you here.

You need to parse the ScanResult's capabilities string in the scanComplete method. According to the Android developer documentation, :

ScanResult.capabilities describes the authentication, key management, and encryption schemes supported by the access point.

You might be able to make use of -- or at the very least use as an example -- the static helper methods available in the AccessPointState class.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top