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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:09:46+00:00 2026-05-17T15:09:46+00:00

I have an IntentService which makes some web service calls. Before making these calls

  • 0

I have an IntentService which makes some web service calls. Before making these calls I check to make sure the device has network connectivity. I am doing so like this:

 private boolean isOnline() {
  ConnectivityManager connec =  (ConnectivityManager)getSystemService(getApplicationContext().CONNECTIVITY_SERVICE);
  return connec.getNetworkInfo(0).isConnectedOrConnecting();
 }

Unfortunately, when I’m debugging on my Android device, this returns false when I have both a network and a wireless connection.

Some interesting tidbits about connec.getNetworkInfo(0):

mIsAvailable = true
mNetworkType = 0
mTypeName = "mobile"
mState.name = "DISCONNECTED"

Clearly this code is not sufficient (perhaps it would only return true if I sent some bit over the network and turned the radio on?). Moreover, since I’m not well versed in the ConnectivityManager, I’m assuming I should probably be scanning all networks (ie: getNetworkInfo(0 through N)).

How can I properly accomplish what I’m wanting here?

  • 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-17T15:09:47+00:00Added an answer on May 17, 2026 at 3:09 pm

    Try this:

    public static boolean isNetworkConnected(Context context){
        ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo network = cm.getActiveNetworkInfo();
    
        if(network != null){
            return network.isAvailable();
        }
    
        return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an IntentService which queues up web service calls to be made. I
I have an IntentService that queues up web service calls that need to be
i have this IntentService code which run a service once: protected void onHandleIntent(Intent intent)
I have an IntentService and I want to make it sticky with an ongoing
I have an IntentService that is parsing some xlm file to create a html
I have an IntentService which updates a preference like this: SharedPreferences.Editor editor = userPrefs.edit();
I have an IntentService that downloads some files. The problem is that I create
i have alarm that calls my intentService every 15 min, in the intentService how
I'm writing an application which needs to make some work every 5 seconds, if
I have a service in my app, as some other apps have, too. From

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.