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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:42:44+00:00 2026-05-30T19:42:44+00:00

In my app i am using soap webservice call , based on the webservice

  • 0

In my app i am using soap webservice call , based on the webservice call reply i have to display some messages .,

But after the reply i could not able to do this from the spawned child thread

So how to get back to the main thread and display this after the reply i got

Hope this is clear.. help me how to achieve my requirement

{
Thread t1 = new Thread() {
public void run() {

    String threadName = Thread.currentThread().getName();
    // There will be delay in this statement while fetching a data from webservice
    String  returnfromWebservice =   webservice(xmlDetails, "generateid");
    Log.v("returnfromWebservice",returnfromWebservice);
    if(  ! returnfromWebservice.equalsIgnoreCase("nil")){ 
        gotid = returnfromWebservice;
        gotReply=true;
    //  dothis();// I could able to do this because this method contains widgets
    //  I am gettin the error : Only the original thread that created a view hierarchy can touch its views.
    //I understand this is because childthread has no controls on widget 
    /**Suggest me how to get back to main thread*/
    }
    }};
t1.start();
dothis();// so i am doin here after the completion of it 


}

public void dothis{
if(gotReply){
    idtext.setText(gotid);
    genId.setEnabled(false);
    Toast.makeText(WelcomeScorer.this, "Generated ", 500).show();
}
else{
    Toast.makeText(WelcomeScorer.this, "Try Once More ", 500).show();
    idtext.setText(gotid);
}
}

I am new to android, Is there any best approach in android api to handle this situation ??

  • 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-30T19:42:45+00:00Added an answer on May 30, 2026 at 7:42 pm

    You should use the following code to touch your ui elements from another thread

    youractivityname.this.runOnUiThread(new Runnable() {
    
                @Override
                public void run() {
                    // TODO Auto-generated method stub
    
                }
            });
    

    If your thread is in same activity you can use this. Otherwise you should use your activity class object to run the above method.
    From your code you should call dothis(); after thread has done its job. From your it will call the dothis method immediately after thread has started it wont care whether thread has done its job or not.

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

Sidebar

Related Questions

I have an app using SQLite3. It's running pretty well, but I would like
I have an app using the ADO.NET entity framework (the VS2008 version, not the
I have 2 SOAP services that I want to call from an IPad app.
I have trying this for some time now but I am not able to
We call a webservice from our C# app which takes about 300ms using WCF
I'm using libxml2 for SOAP-Actions in an iPhone App. The big problem is that
I've created an app that interacts with a SOAP service using java WS. I
I have an app using PHP and the PayPal API. The basic way it
I have an app using a ListView as a main screen. Each row displays
I have an iPhone app using a UINavigationController. On the fourth controller of the

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.