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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:28:11+00:00 2026-06-02T10:28:11+00:00

I have a Main activity with a few methods. GetTopics: calls REST API and

  • 0

I have a Main activity with a few methods.

  • GetTopics: calls REST API and returns JSON results
  • BindTopics: displays the results from GetTopics on the screen

There are a few others with similar functionality, but I’m sure I can fit the solution to these across all methods.

Question: What is the proper way to run these in separate threads? Should both of them be in the same thread? Should I call BindTopics once GetTopics is complete?

Either way, doesn’t the UI get built prior to the async threads are completed? If so, how do I update the UI?

Any help is appreciated.

  • 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-02T10:28:14+00:00Added an answer on June 2, 2026 at 10:28 am

    I would load it in a progress dialog with an AsyncTask. You will need to declare the handler to update controls in the UI thread.

    Example:

    private Handler     handler         = new Handler();
    
    
    final ProgressDialog pd = new ProgressDialog(this);
    pd.setTitle("Getting topics..");
    pd.setMessage("Please while topics are retrieved");
    pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    pd.setIndeterminate(true);
    
    new AsyncTask<Void, Void, Void>() {
    
        @Override
        protected Void doInBackground(Void... params) {
    
            GetTopics();
    
            return null;
        }
    
        @Override
        protected void onPreExecute() {
    
            pd.show();
            super.onPreExecute();
        }
    
        @Override
        protected void onPostExecute(Void result) {
    
            BindTopics();
    
            pd.dismiss();
    
            handler.post(new Runnable() {
    
                public void run() {
                    // update UI
                    // remove loading view
                    // load details of topics
                }
            });
            super.onPostExecute(result);
        }
    
    }.execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a login screen and then the activity which displays the main
i have main activity in which i have Four menus. and i have one
I have a design of activities like this I have one main activity and
I have 3 classes in my example: Class A, the main activity. Class A
I have a widget that supposed to call an Activity of the main app
Say if I have a locationManager(LM) object in activity A, which is my main
I have this situation where i have to start an activity from my mainActivity.
I have a simple main activity with 3 buttons, and a background service that
I have a few dozen activities: 1-Main, 1-Animation, 10-Other's and it's sub-sets of more
Lets say i have a few activity A,B and C. Activity A is run

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.