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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:13:41+00:00 2026-06-17T21:13:41+00:00

I am connecting to a terminal emulator using a library in android, this connects

  • 0

I am connecting to a terminal emulator using a library in android, this connects to a serial device (a switch) and shows me sent/received data. I send data over the connection via a text box below the terminal or by typing in the terminal itself and hitting enter on the keyboard in both cases. I can also send commands by pressing buttons.

My problem is whenever the terminal itself is highlighted the UI does not update, as in the commands sent with the buttons, or data received from the serial device. I can type in the terminal itself and the characters come up. If the editText is selected everything updates fine. So if I select the terminal and send a command, it will only be displayed to the screen once I select the editText. A lot of the time after I select the editText it still does not update until I press the terminal again. Very strange. So my invalidate is not working well? Or is it this notifyUpdate method that I am using and don’t really understand?

What I currently do is call a method when data is received, this method calls a handler which updates the screen every 1000ms. This however does not work when the terminal is selected, why is this? I am getting the error: “Only the original thread that created a view hierarchy can touch its views.”

Screenshot: https://i.stack.imgur.com/1m26B.png

    //terminal view
    EmulatorView view = (EmulatorView) findViewById(R.id.emulatorView);
    mEmulatorView = view;

    public void onDataReceived(int id, byte[] data)
    {
    dataReceived = new String(data);
    ((MyBAIsWrapper) bis).renew(data);
    mSession.write(dataReceived);
    mSession.notifyUpdate();
    viewHandler.post(updateView);
    }

    Handler viewHandler = new Handler();
    Runnable updateView = new Runnable() {
    @Override
    public void run() {
    mEmulatorView.invalidate();
    viewHandler.postDelayed(updateView, 1000);

        }
    }
};

Relevant code from library I’m using:

 [code]protected void notifyUpdate() {
        if (mNotify != null) {
            mNotify.onUpdate();
        }
    }[/code]

and

/**
 * Generic callback to be invoked to notify of updates.
 */
public interface UpdateCallback {
    /**
     * Callback function to be invoked when an update happens.
     */
    void onUpdate();
}

This is the description of the method notifyUpdate() – Method in class jackpal.androidterm.emulatorview.TermSession Notify the UpdateCallback registered by setUpdateCallback that the screen has changed.

I thought it might be mSession.notifyUpdate(); in my code, but apparently if I comment that out the same error occurs, that line seems to be doing nothing for me anyway. I’m not sure where the error is to fix it so that my screen is always being updated no matter where I am pressing.

  • 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-17T21:13:42+00:00Added an answer on June 17, 2026 at 9:13 pm

    Got it working, I just had to run that write line in a UI thread, even thought I though it was?!

    public void onDataReceived(int id, byte[] data) {
    
            dataReceived = new String(data);
            ((MyBAIsWrapper) bis).renew(data);
    
            runOnUiThread(new Runnable(){
                @Override
                public void run() { 
                    mSession.write(dataReceived);       
                }});
    
            viewHandler.post(updateView);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am connecting to a terminal emulator using a library in android, this connects
I am connecting to a terminal emulator using a library in android, this connects
I am connecting to a terminal emulator using a library in android, this connects
I am connecting to a terminal emulator using a library in android, this connects
I am trying to connect to a terminal emulator using a library in android,
Updated question: I am trying to connect to a terminal emulator using a library
We have a terminal emulator (its more then just this, but for the question
I am programming a Windows CE 6 device (Motorola MC3100 scanner Terminal). Using Lazarus
Background To capture data from a logic controller, I'm using screen as a terminal
When connecting to sql server, I have the hardcoded string (local). Is this 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.