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 9201709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:04:54+00:00 2026-06-17T23:04:54+00:00

When WIFI_STATE_ENABLED is received by my BroadcastReceiver directly after that the SSID value of

  • 0

When WIFI_STATE_ENABLED is received by my BroadcastReceiver directly after that the SSID value of WifiInfo is null. However it works when I add a Thread.Sleep() for 800 milliseconds. There seems to be a delay in the event connecting the wifi and the WifiInfo object actually getting the information. The snippet below works:

    else if (intent.getAction().equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
        int extraWifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN);
        switch (extraWifiState) {
        case WifiManager.WIFI_STATE_ENABLED:
            // The SSID is null just after connection is established. This
            // event seems over eager.
            try {
                Thread.sleep(800, 0);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (!wifiFunctions.connectedToGConnectHotspot()) {
                removeConnectedNotification();
            } else {
                settings.setLastNotificationTime(System.currentTimeMillis());
                notifyUserOfAvailableHotspot(true);
                return;
            }
            break; 

That works but it is extremely dodgy. What if it takes longer on some devices? Is there another way to get the connected SSID. I looked and EXTRA_NETWORK_INFO but it is deprecated as of API level 14 and also does not seem to include the SSID anyway. Is there another method to get the SSID without introducing an artificial wait?

  • 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-17T23:04:56+00:00Added an answer on June 17, 2026 at 11:04 pm

    WIFI_STATE_ENABLED is not the action you want to capture if you’re looking to get the SSID. The one you might be more interested is NETWORK_STATE_CHANGED.

    The WIFI_STATE_ENABLED occurs when the WiFi device on the phone is switched on – it’s not necessarily connected anywhere at that point.

    Edit: as pointed out in the comments, NETWORK_STATE_CHANGED triggers on many other events too. For strictly monitoring connection to WiFi access point, SUPPLICANT_CONNECTION_CHANGE_ACTION is the correct action to listen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a snippet of code that I'm calling from a service: context.registerReceiver(new BroadcastReceiver()
I'm new to Android development and working on an Android application that requires the
I'm new to android. I want to receive information via broadcastreceiver ( onReceive )
I made a splash screen and used a runnable thread to parse a xml
I was wondering if I could get a second (or many for that matter)
I noticed that there are two types of permissions in the manifest file, permission
I have to write an application that would work as 'Device Hardware Admin'. The
In Service I want to register BroadcastReceiver for android.net.wifi.WIFI_STATE_CHANGED public void onCreate() { super.onCreate();
This is my main thread: Thread t = new Thread(){ @Override public void run()
I have an application that tries to be a good samaritan, basically, when any

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.