Skip to content Skip to sidebar Skip to footer

Android Ui Thread Issue

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

Solution 1:

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);
    }

Post a Comment for "Android Ui Thread Issue"