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

  • Home
  • SEARCH
  • 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 6086701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:47:08+00:00 2026-05-23T11:47:08+00:00

This is what I would like to do : => IF WiFi is enabled

  • 0

This is what I would like to do :

=> IF WiFi is enabled AND active, launch an intent (in fact it’s a WebView that gets its content=>the instructions of my app on the web)

=> IF NOT, then I would launch another intent so that I don’t show a WebView with “Web page not available … The Web page at http://www.mywebsite.com might be temporarily down or it may have moved …”

I tought initially to use

if(wifi.isWifiEnabled())

but that does not say if the Wifi connection is ACTIVE or not. It says only that the user has turned the switch on. The device may or may not be connected… Is this correct ?

Then I tried to use :

if (wifi.getConnectionInfo().getSSID()!= null)

but I noticed that it returns a string even if the connection has been lost or has been disabled … ?

How should I do then ?

wifi = (WifiManager)getSystemService(Context.WIFI_SERVICE);
Intent intent_instructions;

            if (wifi.getConnectionInfo().getSSID()!= null){
                Log.i("Hub", "WiFi is enabled AND active !");
                Log.i("Hub", "SSID = "+wifi.getConnectionInfo().getSSID());
                intent_instructions = new Intent(this, Instructions.class);
            }else{
                Log.i("Hub", "NO WiFi");
                intent_instructions = new Intent(this, Instructions_No_WiFi.class);
            }
            this.startActivity(intent_instructions);

Is there a more general way to test if the device has the connectivity to the internet just before launching an intent ? be it through Wifi, 3G, etc …

Thanks in advance for your help.

  • 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-05-23T11:47:09+00:00Added an answer on May 23, 2026 at 11:47 am

    You can use the following code to check for connectivity:

    private static boolean isConnected(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager)
            context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = null;
        if (connectivityManager != null) {
            networkInfo =
                connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        }
        return networkInfo == null ? false : networkInfo.isConnected();
    }
    

    Please make sure that you’ve registered the android.net.conn.CONNECTIVITY_CHANGE intent in your Manifest, or else, you’ll never receive a notification that you’re online.

    I’ve been struggling with this issue for the last couple of days and I just now realized that I needed to register CONNECTIVITY_CHANGE and not only WIFI_STATE_CHANGED.

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

Sidebar

Related Questions

I have an application that used Macro. In this macro I would like to
I would like to setup a multi-tenant ASP.NET MVC app. Ideally, this app would
I would like this to be the ultimate discussion on how to check if
Is there any reason something like this would not work? This is the logic
This has always confused me. It seems like this would be nicer: ["Hello", "world"].join("-")
I am getting tricked up with arrays and nested arrays. I would like this
I have a pure C++ application developed using VC 6.0. I would like this
I would like to replicate this in python: gvimdiff <(hg cat file.txt) file.txt (hg
I would like to know this to understand why some games like Mario is
I would like to do something like this: a rotating cube on a form.

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.