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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:56:14+00:00 2026-06-04T11:56:14+00:00

i want to post some message with setText() method inside thread when readline!= null,

  • 0

i want to post some message with setText() method inside thread when readline!= null, but i found error. I can’t show toast and use setText() method.

public void run(){

    Looper.myLooper();
    Looper.prepare();

    try {           
        while(!((line = in.readLine()).equalsIgnoreCase("quit"))){              
            if(line.isEmpty()){
                System.out.println("there is no message");
            }else{                      

     Toast.makeText(this, "Message= " + line , Toast.LENGTH_SHORT).show();
                msgbox.setText(line);
            }               
        }           
    } catch (IOException e) {
        e.printStackTrace();
        System.out.println("Gagal mengirim ACK ke server");
    }

}
  • 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-04T11:56:15+00:00Added an answer on June 4, 2026 at 11:56 am

    what is your error?

    can this code solve it?

        try {       
    
                final StringBuffer strMessage = new StringBuffer();
    
            while(!((line = in.readLine()).equalsIgnoreCase("quit"))){              
                if(line.isEmpty()){
                    System.out.println("there is no message");
                }else{                      
    
                strMessage.append(line)
    
                this.runOnUiThread(new Runnable() {
            public void run() {
                Toast.makeText(YourActivity.this, "Message= " + line , Toast.LENGTH_SHORT).show();
                 msgbox.setText(strMessage.toString());
                //...
                        }
                    });
    
                }               
            }           
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("Gagal mengirim ACK ke server");
        }
    

    runOnUiThread(…) Runs the specified action on the UI thread. If the current thread is the UI thread, then the action is executed immediately. If the current thread is not the UI thread, the action is posted to the event queue of the UI thread.

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

Sidebar

Related Questions

I want to post on twitter wall but don't want that user can edit
I want to post some message on Facebook wall. I am able to log
I want some help friends, I want to Post XML string in SOAP message
I want to send some data to a server through POST method in android.
I want to post some data via javascript to another domain. Something like: http://www.othersite.com/submitfunnyname?name=blah
I want to post some values from a simple HTML form, validate them with
I want to post a message on the user's facebook wall using access token.
how can I post data without using NameValuePair ? I want to post String
I am successfully posting to Facebook wall, but I want that user can choose
I have created an app, and now i want to post a message on

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.