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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:23:12+00:00 2026-05-25T23:23:12+00:00

I want to make an http request (I use ksoap2) in the onCreate() during

  • 0

I want to make an http request (I use ksoap2) in the onCreate() during this time I want to have a ProgressDialog on screen to block the user. Once the request is done, I want to finish my onCreate using the elements that I retrieve from my http request.

For now:

I have a class which implements Runnable. I instantiate it in my onCreate. This class make the http request, during this time a ProgressDialog is on the screen. Once it’s done the ProgressDialog is dismissed. But since it’s not in the UI thread the following of the onCreate is executed before getting the result of the http request.

I also tried, at first: in the onCreate I do a show() of my ProgressDialog then the http request then a dismiss() ProgressDialog and finally finish my onCreate with the result of my http request… it’s ok except that the ProgressDialog is not showing this time.

Sorry for the messy explanations, my english is really not helping either.

Anyway, ideas ?

Thanks.

PS : BTW I know AsyncTask is better, it is what I usually use but having it with a ProgressDialog is not at all easy.

My question is more : is there a way in an onCreate() to make an http request to get the value of an int. While this request is made: showing a ProgressDialog to block the user but also block the UI thread so that the end of the onCreate can use the value retrieved by the http request once it is complete.

An ugly way would be a loop in the onCreate with a sleep waiting for the value to be retrieved… that’s really ugly.

  • 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-25T23:23:12+00:00Added an answer on May 25, 2026 at 11:23 pm

    Edit: I know you mentioned you didn’t want to use AsyncTask due to the complexities of showing the ProgressDialog, but unless I’m missing something it should be as simple as the below. Alternatively, you could use a handler to fire the call back?

    I think you need some kind of handler to callback once the HTTP request is done, and then in the callback finish off your code.

    I also use ksoap2 for a web service call and show a ProgressDialog whilst it’s called. Once the web server call is finished, it raises an event and I close the ProgressDialog. I’m not sure if this will help you, but I have the following (of course, there may be better ways, but this works for me), this way the ProgressDialog is called on the UI thread, an AsyncTask completes and calls the complete method (which returns the thread back to the UI) and I dismiss the dialog:

        // Notify user the web service is connecting
        final ProgressDialog dialog = ProgressDialog.show(
                Screen_GlobalLeaderboard.this, "Getting scores",
                "Please wait...", true);
        dialog.setCancelable(true);
    
        WebService ws = new WebService(this) {
    
            @Override
            public void webServiceCallComplete(boolean success, Object data,
                    String errorMessage, WebMethods callingWebMethod) {
    
    
                dialog.dismiss();
    
                // Your complete code here
            }
        };
    
        ws.getTopLeaderboardResults(top, gameMode);
    

    Edit: I think what you’re asking is onCreate (ran from the UI thread), you want to show a ProgressDialog and in the same method return a value from an HTTP request and once it completes, hide the dialog.

    You then say you’ve tried that and the ProgressDialog does not show. This is because you block the UI thread with the HTTP request.

    Providing you call the HTTP request from the onCreate method, you must run it in a separate thread (or as you done, implement Runnable) and a handler which will call the runnable with which you can then handle the return value.

    Put simply, you can’t:

    Show ProgressDialog > Call HTTP request > Get value > Hide ProgressDialog without adding another thread for the HTTP request (or the ProgressDialog will not show) which in turn means your return HTTP request code must be outside of the calling onCreate method.

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

Sidebar

Related Questions

I want to make a http request with android. is use this: void testHTTP()
I want to make a dropdown menu like delicious has at this http://delicious.com/search?context=all&p=sql&lc=1 page.
I want to make an Http request and store the result in a JSONObject.
I want to be able to make an HTTP call updating some select boxes
I have style sheet with a class name changebackgroundcolor i want make change in
I am trying to make a get http request using jquery getJSON function. I
We have a server control that we want to use in our .net MVC
I make use of a great class made by Jaisen: http://github.com/jmathai/twitter-async/tree/master . Recently twitter
I have an application that needs to make a SOAP client request to a
This question is for my curiosity only: Is it possible to make a HTTP

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.