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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:00:21+00:00 2026-06-15T15:00:21+00:00

how can I show a loading image when this code running ? HttpClient client

  • 0

how can I show a loading image when this code running ?

HttpClient client = new DefaultHttpClient();
      HttpGet request = new HttpGet("http://www.google.com");
      try
      {
          HttpResponse response = client.execute(request);
          BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
          String line;
          StringBuilder str = new StringBuilder();
          while((line = reader.readLine()) != null) {
              str.append(line);
      }
          objwebview.loadData(str.toString(), "text/html", "UTF-8");
  }
  catch(Exception e)
  {
      e.printStackTrace();
      objwebview.loadData(e.toString(), "text/html", "UTF-8");
  }
  • 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-15T15:00:22+00:00Added an answer on June 15, 2026 at 3:00 pm

    Change your code as for showing loading bar using AsyncTask

    private class Getdataasynktask extends AsyncTask<String, Void, String> {
    
    ProgressDialog progressDialog = new ProgressDialog(context);
    
          @Override
          protected void onPostExecute(String result) {     
          // show loaging bar here
    
        progressDialog.setMessage("Loading...");
        progressDialog.setCancelable(false);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setProgress(0); // set percentage completed to 0%
        progressDialog.show();
              
          }
    
          @Override
          protected String doInBackground(String... params) {
              String strdata= getdatafromserver();
                return strdata;
          }      
    
          @Override
          protected void onPreExecute(String result) {
            
           objwebview.loadData(result.toString(), "text/html", "UTF-8");
           // dismiss progress bar here
           progressDialog.dismiss();
          }
     public String getdatafromserver(){
         String line;
          objwebview.loadData(str.toString(), "text/html", "UTF-8");
          HttpClient client = new DefaultHttpClient();
          HttpGet request = new HttpGet("http://www.google.com");
          try
          {
              HttpResponse response = client.execute(request);
              BufferedReader reader = new BufferedReader(new 
                        InputStreamReader(response.getEntity().getContent()));
             
              StringBuilder str = new StringBuilder();
              while((line = reader.readLine()) != null) {
                  str.append(line);
          }
              
      }
      catch(Exception e)
      {
          e.printStackTrace();
          line=e.toString();
         
      }
    return line;
    }
    }
    

    for executing this AsyncTask from UI Thread use

    new Getdataasynktask().execute("");
    

    and you can also use onProgressUpdate and publishProgress for showing loading bar using AsyncTask and publishing results to Ui thread . for more info see

    http://developer.android.com/reference/android/os/AsyncTask.html

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

Sidebar

Related Questions

In Prototype I can show a loading... image with this code: var myAjax =
i have this code running to load my images all asynch and show a
I want to design a splash screen that can show the current loading process
How can I delay the app loading to show the splash screen for longer?
I would like to know how I can show the output from this piece
I am looking for a control which can show me selected image detail view
I'm trying to show a small loading image during a slow operation with jQuery
How to resize the Picturebox so it can show the full image if the
I am using this code to show scrolling images but I am only getting
Scenario: User loads a page, image is being generated, show loading bar, notification event

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.