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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:31:10+00:00 2026-05-22T20:31:10+00:00

I am using the following code to see if user have internet connection (WIFI

  • 0

I am using the following code to see if user have internet connection (WIFI or 3G or Edge).
Why does some users get “No internet connection” when they do have it?

try{
  ConnectivityManager connec =  (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
            State wifi = connec.getNetworkInfo(1).getState();

  if (connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED ||
    connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTING || 
    wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING ) {
    ///HAVE CONNECTION CODE////
            }else if ( connec.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED ||   connec.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED   ) {
    ///NO CONNECTION CODE///
  }
} catch (Throwable t){
///NO CONNECTION CODE///
}
  • 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-22T20:31:11+00:00Added an answer on May 22, 2026 at 8:31 pm

    My guess would be that connec.getNetworkInfo(0) and connec.getNetworkInfo(1) aren’t always valid for the wifi/3g network interfaces. Try checking the ‘TypeName’ of the interfaces. I use this code…

    public boolean HaveNetworkConnection() {
        boolean HaveConnectedWifi = false;
        boolean HaveConnectedMobile = false;
    
        ConnectivityManager connManager = (ConnectivityManager) appContext.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo[] netInfo = connManager.getAllNetworkInfo();
        for (NetworkInfo ni : netInfo) {
            Log.d("HaveNetworkConnection()", ni.toString());
            if (ni.getTypeName().equalsIgnoreCase("WIFI"))
                if (ni.isConnected())
                    HaveConnectedWifi = true;
            if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
                if (ni.isConnected())
                    HaveConnectedMobile = true;
        }
        return HaveConnectedWifi || HaveConnectedMobile;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following pseudo code using EF Code First: User user = GetFromCache();
Using following code I try to get updated list of checkbuttons' corresponding text values,
I am using following code to create new wifi access point and to connect
So I am using Silverlight 4.0 I have the following code but its giving
I am using the following code: while (invalidInput) { // ask the user to
I am using the following code, upload.php, to try to have someone upload a
I have the following code that sends a message using the mail() function. Everything
I have a login page using jQuery Mobile which contains the following code: <div
I have a jquery datatable using the following code: // Test list table $('#dashboard_testlist_table').dataTable({
I have the following code which I am are currently using .... Basically, this

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.