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

The Archive Base Latest Questions

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

I have an application where i want to find every time it connect with

  • 0

I have an application where i want to find every time it connect with internet and fetching data from internet how much time it will take?
and if takes more time then i want to give warning to user that “problem with Internet connection”

So how I can know how much time it ll take., below a function of my application I gave, where HttpResponse i used.plz tell me how to get how much time it will take to give the response

 String page = executeHttpGet("http://192.168.1.109/temp/android.php");

 private String executeHttpGet(String URL) throws Exception {

    BufferedReader bufferedReader = null;
    try {
        HttpClient client = new DefaultHttpClient();
        client.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
                "android");
        HttpGet request = new HttpGet();
        request.setHeader("Content-Type", "text/plain; charset=utf-8");
        request.setURI(new URI(URL));
        HttpResponse response = client.execute(request);
        bufferedReader = new BufferedReader(new InputStreamReader(response
                .getEntity().getContent()));

        StringBuffer stringBuffer = new StringBuffer("");
        String line = "";

        String NL = System.getProperty("line.separator");
        while ((line = bufferedReader.readLine()) != null) {
            stringBuffer.append(line + NL);
            System.out.print(stringBuffer);
        }
        bufferedReader.close();
        page = stringBuffer.toString();
        System.out.println(page + "page");
        return page;
    } finally {
        if (bufferedReader != null) {
            try {
                bufferedReader.close();
            } catch (IOException e) {
                Log.d("BBB", e.toString());
            }
        }
    }
}

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-05-23T02:11:48+00:00Added an answer on May 23, 2026 at 2:11 am

    ..if takes more time then i want to
    give warning to…

    Since you know the best time you should get a response why not specify a timeout when creating a connection. See the code snippet below on how to set the timeout. You then catch the timeout error and notify that the service too long to respond.

    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpParams params = httpClient.getParams();
    HttpConnectionParams.setConnectionTimeout(params, 5000);
    HttpConnectionParams.setSoTimeout(params, 5000);
    
    ClientExecutor executor = new ApacheHttpClient4Executor(httpClient);
    

    Ref:

    1. http://blog.jayway.com/2009/03/17/configuring-timeout-with-apache-httpclient-40/
    2. Http connection timeout on Android not working
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application and I want to move some of the tables from
We have an application that we want to make available to the general internet-using
I have an application where I want to format a currency using the country's
I have a application and I want to show the contacts are sorted by
I have an application where I want to simulate the connection between a device
I have this application that I want to support multi languages. I thought the
i have application who use specific process during running and i want to sample
I have an application and executables. I want my application to run my executables.
I Have application is implemented in JSP, HTML, JS, CSS and now i want
In my application I want to have one view that holds 2 partial views.

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.