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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:40:11+00:00 2026-06-11T23:40:11+00:00

I could’t find any helpful tutorials on internet nor the documentation on developers site.

  • 0

I could’t find any helpful tutorials on internet nor the documentation on developers site.

In my application i am connecting to a Web Server using HttpPost, when there is no internet connection, but wifi is on it shows a white screen and after some 10-15 secs “UnknownHostException”.

I caught this Exception and made toast like

Unable to connect, check your internet connection.

and close the Activity (or the Application, since i am using finish() on the 1st Activity).

When the wifi itself is off i get an instant toast like”

You need internet connection to use this Application

but the 1st case is irritating. Taking 10-15 secs time and then showing the toast.

So i used HttpParameters and added a 5 sec ConnectionTimeout parameter.

But the application works same as before(no effect of this parameters).

How can i track if i hit ConnectionTime(5 secs over). So that i can show a Toast like

Slow internet connection

moreover why is the internet connection check not working when wifi is on but no internet

this is what i check when my application is lauched:

cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

if (isOnline(cm, this, SignUpActivity.this)){
//continue
}

public static boolean isOnline(ConnectivityManager cm, Context c, Activity a) {

    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    if (netInfo != null && netInfo.isConnectedOrConnecting()) {
        return true;
    }

    Toast.makeText(c, "You need internet access to run this application",
            Toast.LENGTH_SHORT).show();
    a.finish();
    return false;
}

am i only checking whether device’s wifi is on. if so, how can i check whether i have internet connection, instead of just wifi

Thank You

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

    As for the first question, try using SocketTimeout instead.

    As for the second question, the line

    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    

    Will only get Wi-fi status (i.e. phone wifi antenna turned on) but not actual connectivity. The function returns immediately, so that if wifi is turned off you can toast out without checking connection further. But when wi-fi is turned on, you should go on and check your server’s actual reachability, with something like

    InetAddress.getByName(host).isReachable(timeOut)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could any body kindly advise me about the app.config file. When application is complied,
Could someone suggest me any good beginners guide on how to create web pages
Could someone point out good tutorials/books for learning how to use/configure Hibernate in Android
Could you please let me know whether weblogic-application.xml can be added in a WAR
Could you please explain, do I really need to install git server on the
Could someone recommend any good resources for creating Graphics User Interfaces, preferably in C/C++?
Could any one give an explanation on how a DHT works? Nothing too heavy,
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
Could anyone give a complete example on using the tastypie FileField, both server-side and
Could someone know where is saved path to external XML-File that contain configuration for

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.