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

  • Home
  • SEARCH
  • 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 8789537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:26:09+00:00 2026-06-13T22:26:09+00:00

Due to android doc , The task can be executed only once. I’m trying

  • 0

Due to android doc , The task can be executed only once.

I’m trying to run HttpClient in UI-Thread. But it allows for the only once. If I want to get another data from another link which is not yet run at the first start, how can I do it? Until I get all data when the app starts for the first time, it takes long time. Is there anyone who knows how to solve this problem ?

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

    You’re running a network operation on main thread. Use async task to run network operations in background thread (do your http requests in a background thread).

    Do your networking in an async task like this:

    class WebRequestTask extends AsyncTask{
    
    
        protected void onPreExecute() {
        //show a progress dialog to the user or something
        }
    
        protected void doInBackground() {
            //Do your networking here
        }
    
        protected void onPostExecute() {
            //do something with your 
           // response and dismiss the progress dialog
        }
      }
    
      new WebRequestTask().execute();
    

    Here are some tutorials for you if you don’t know how to use async tasks:

    http://mobileorchard.com/android-app-developmentthreading-part-2-async-tasks/

    http://www.vogella.com/articles/AndroidPerformance/article.html

    Here are the official docs from Google:

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

    You can call the async task multiple times whenever needed to perform the download tasks. You can pass parameters to the async task so that you can specify what data it should download (for example by passing a different url each time as a parameter to the async task). In this way, using a modular approach, you can call the same aync task multiple times with different parameters to download the data. The UI thread wont be blocked so the user experience will not be hindered and your code will be thread safe too.

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

Sidebar

Related Questions

I am developing an android app that should only run in portrait mode due
I'm trying to port an old VB.NET application to an Android application, but due
i am trying to make facebook asynchronous non blocking thread in android. due to
uncaught handler:thread main exiting due to uncaught exception android.app.SuperNotCalledException:Activity did not call through to
I have installed my Android SDK in Program Files (x86). But due to some
Multithreading on Android is to some extent an easy task due to the various
Lately I have been thinking about developing some basic android app. Its only due
I believe I read at some point that due to Android running on the
I'm developing an Android app, and due to time circumstances, I started developing the
I'm having problems building a project under the Android NDK. Most likely its due

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.