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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:09:26+00:00 2026-06-15T23:09:26+00:00

I am trying to connect to a terminal emulator using a library in android,

  • 0

I am trying to connect to a terminal emulator using a library in android, this will connect to a serial device and should show me sent/received data. To attach to a terminal session I need to provide an inputstream to setTermIn(InputStream) and an outputstream to setTermOut(OutputStream).

However when I declare the streams as follows they default to null don’t they?

private OutputStream bos;
private InputStream bis;

...

//inside onCreate() method
session.setTermIn(bis);
session.setTermOut(bos);
/* Attach the TermSession to the EmulatorView. */
mEmulatorView.attachSession(session)

So when I try to attach my streams to the session i get an error:

FATAL EXCEPTION: TermSession input reader
java.lang.NullPointerException at jackpal.androidterm.emulatorview.TermSession$2.run(TermSession.java:137)

which points to this code in the library:

public void run()
{
    try
    {
        while (true)
        {
            int read = mTermIn.read(mBuffer);
            if (read == -1)
            {
                // EOF -- process exited
                return;
            }
            mByteQueue.write(mBuffer, 0, read);
            mMsgHandler.sendMessage(mMsgHandler.obtainMessage(NEW_INPUT));
        }
    }
    catch (IOException e)
    {
    }
    catch (InterruptedException e)
    {
    }
}

This is because I haven’t started sending and receiving data yet so I haven’t assigned the data to the streams. What do i do, set up some spurious data to assign to a stream?
I tried that and it complains still. Perhaps I am doing it wrong.

To send and receive data i have the following methods, although I shouldn’t be setting the stream every time I call them I imagine.

Overriding the method that sends data over serial to set up the stream, runs whenever I press enter:

public void sendData(byte[] data)
{
    bos = new ByteArrayOutputStream(data.length);
}

Runs whenever data is received:

public void onDataReceived(int id, byte[] data) 
{
    bis = new ByteArrayInputStream(data);
}

How do I initialize these correctly? And should I really be setting the stream every time I send and receive data, does it matter? Or should I do some check?

  • 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-15T23:09:27+00:00Added an answer on June 15, 2026 at 11:09 pm

    You must initialize bis and bos before using them

    You can put it just before using these two line

    session.setTermIn(bis);
    session.setTermOut(bos);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to connect to a terminal emulator using a library in android,
Iam trying to connect my android device with a bluetooth compatible device. I know
I am trying to run Hierarchy Viewer. developer.android.com says to Connect your device or
I am trying to connect to a MySQL Server using JDBC tool in java
I am trying to connect the JSF to database. This are the files web.xml
I'm trying to connect to a FTP using Apaches FTPSClient but I keep getting
I'm trying to connect java to a Oracle database within terminal. I'm not very
I'm using HostMonster as my web host and I'm trying connect to a database
I'm trying to connect to my localhost MySQL server via php in the terminal.
I am using Paramiko and trying to connect to my SFTP server. Here is

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.