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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:38:31+00:00 2026-06-10T04:38:31+00:00

When my users click the login button I want to hit my webservice. I

  • 0

When my users click the login button I want to hit my webservice. I have the following code to do so.

public void onClick(final View view) {
  String orgKey = inputCompany.getText().toString();
  new getAppInfo().execute("http://example.webservice.com");

Here is my getAppInfo

   private class getAppInfo extends AsyncTask<String, Void, String> {
    /** The system calls this to perform work in a worker thread and
      * delivers it the parameters given to AsyncTask.execute() */
    @Override
    protected String doInBackground(String... urls) {
        String xml = null;
        try {
            // defaultHttpClient
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet(urls[0]);

            HttpResponse httpResponse = httpClient.execute(httpGet);
            HttpEntity httpEntity = httpResponse.getEntity();
            xml = EntityUtils.toString(httpEntity);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        // return XML
        return xml;
    }

    /** The system calls this to perform work in the UI thread and delivers
      * the result from doInBackground() */
    @Override
    protected void onPostExecute(String result) {
        Document doc = GetDomElement(result); // getting DOM element

        NodeList nl = doc.getElementsByTagName("details");
        getChildElements(nl); 
    }

The doBackground is running but the onPostExecute is not. I have moved it out of the on click and it has worked but I need it inside the onClick.

How can I get it to run the onPostExecute inside my onClick?

  • 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-10T04:38:32+00:00Added an answer on June 10, 2026 at 4:38 am

    The syntax is correct you might be getting an exception in the background process, stopping the background thread. put a log statement at the end of your doInBackground or add a catch (Throwable t) to your try.

    Have faith – it WILL be called as long as doInBackground completes successfully.

    As an aside, you should do your DOM parse in the background as well – at the moment you are doing it in the UI thread which may cause ANR popups.

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

Sidebar

Related Questions

I have an input field and a login button. I want to allow users
We want to let users click a thumbs up or thumbs down button from
I have a button in my abc.html page <input type=button onclick=javafun();> on the click
I have a facebook connect button on this site here is the code <fb:login-button
I have a login form, when you Click the login button the form fadesIn(),
When users click on a button (with id graph), I'd like to fill the
I am showing a modal popup when someone click login button and then they
`I have fetched all the pages of users using manage_page permission, using this code
I want to insert the data in a SQLite table login when a button
Creating a login page in xcode 4.2 I have the users fill out information

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.