Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7727065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:21:58+00:00 2026-06-01T05:21:58+00:00

so I have trawled true all threads in here and any where else where

  • 0

so I have trawled true all threads in here and any where else where google would take me. But still I am having problems connecting to WPA PSK networks.
Here is my code, I have 2 edittext fields from which I read SSID and PSK and then one checkbox to select if SSID is hidden or not.

    EditText mSSID = (EditText) findViewById(R.id.wifiTVssidcurrent);
    String networkSSID = mSSID.getText().toString();
    EditText mWPA = (EditText) findViewById(R.id.wifiTVwpacurrent);
    String networkWPA = mWPA.getText().toString();

    // Update text to show that connection is pending
    TextView wifiStatus = (TextView) findViewById(R.id.wifiTVconnectionstatus);
    wifiStatus.setText("Connecting to " + networkSSID);

    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); 
    WifiConfiguration wc = new WifiConfiguration(); 
    wc.SSID = "\"".concat(networkSSID).concat("\""); 
    wc.preSharedKey  = "\"".concat(networkWPA).concat("\"");

    CheckBox mSSIDHidden = (CheckBox) findViewById(R.id.wifiCBhiddenssid);
    wc.hiddenSSID = false;
    if (mSSIDHidden.isChecked()) {
        wc.hiddenSSID = true;
    }
    wc.status = WifiConfiguration.Status.ENABLED;         
    wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); 
    wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); 
    wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); 
    wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); 
    wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); 
    wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
    int res = wifi.addNetwork(wc); 
    Log.d("WifiPreference", "add Network returned " + res ); 
    boolean b = wifi.enableNetwork(res, true);         
    Log.d("WifiPreference", "enableNetwork returned " + b );
    boolean c = wifi.reconnect();
    Log.d("WifiPreference", "reconnect returned " + c );

What I see in the phone after running this is that an AP is created in settings, but it is not connecting. And if I try to use the created AP manually from settings afterwards I am not able to connect either.
But if I create the AP from within settings I get connection as I should.

As for putting SSID and WPA PSK in I have tried both “\””.concat(networkSSID).concat(“\””); and “\””+ networkSSID +”\””; with same result.

Any tips will be very welcome.
Best regards
Lasse

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:21:59+00:00Added an answer on June 1, 2026 at 5:21 am

    Again big thanks to Ryan for proposing how to read the settings created by the OS.

    So I thought I had tried everything suggested here on stack overflow.
    But this thread actually helped me in the end Setup wifi programatically using WPA Security in android tablet So big thanks to RYAN for providing the tips on reading one AP and then mimmick it. In my case it turned out that I needed to add Even though I am setting up for WPA I still needed to add allowedGroupCiphers WEP40 and WEP104 And I only had

    `wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN); //So I also added 
     wc.allowedProtocols.set(WifiConfiguration.Protocol.WPA);`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've trawled the SO website thinking this is pretty obvious but alas I have
Jquery wont load. I'm a noob, but have persisted, trawled this site & tried
I have followed numerous screen casts as well as trawled the backbone docs extensively
have not tested on windows. but in ubuntu when u disconnect from the network,
I've trawled through Google for days on end now trying to find a solution
Have converted devise new session from erb to Haml but doens't work, this is
Have searched the database but need to specifically sum(of hours flown or days off)in
I know this question has been posted here before, and I've trawled through as
I have gotten this to work nicely, but when speed hits a certain speed
Have just started using Google Chrome , and noticed in parts of our site,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.