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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:56:44+00:00 2026-06-03T08:56:44+00:00

In my application I need to update the text in the UI depending upon

  • 0

In my application I need to update the text in the UI depending upon the data from the network.For that I am using a AsyncTask to do work in background in Android. My code is as follows.

public class DefaultActivity extends Activity{

  TextView textView;
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    textView=(TextView)findViewById(R.id.textId);
    new networkFileAccess().execute("background","Progress","result");
  }

  private class networkFileAccess extends AsyncTask<String,String,String>{

    protected String doInBackground(String... background){
       return changeText();
    }

    private String changeText(){
     //Code to Access data from the Network.
     //Parsing the data.
     //Retrieving the boolean Value.
     if(booleanistrue){
      //Displaying some text on the UI.
      publishProgress("someTextOnUI");
      //Send request till we get get boolean value as false.
      changeText();
     }else{
       return "success";
     }
      return "";
    }

    protected void onProgressUpdate(String... progress){
      textView.setText("Wait background work is going on");
    }

    protected void onPostExecute(String result){
      if(result.equals("success")){
       //Code to finish the activity.
      }
    }
  }

}

In the above code I am able to run the background thread till I get boolean value as false.But the text is not updating on the UI. Can I update the text on the UI using onProgressUpdate() method by calling publishProgress method.?Any suggesstions.

  • 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-03T08:56:45+00:00Added an answer on June 3, 2026 at 8:56 am

    Put your Ui method inside runonUiTHREAD like this

    runOnUiThread(new Runnable() {
    public void run() {
        tv.setText("ABC");
    }
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here's my question: I have an MVC3 C# application and I need to update
i need to update my application so it can support retina display in New
In my Application I need to call a function(Which update the valuesof textviews),I need
I need to write a simple C# .NET application to retrieve, update, and insert
I need to create a plug-in that updates an application. Look, I have a
I need to invalidate cache in a web application when related data is updated
In the java web application need to select the file from server and print
I have two application that need to talk to each other. App1 needs to
Note(update): No need to read this entire wall of text.. problem + solution further
For an application we are developing we need to read n rows from a

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.