D
D
Dmitry2020-03-03 15:46:18
Java
Dmitry, 2020-03-03 15:46:18

Displaying a string in a TextView?

Once a second, data arrives via USB
on arrival starts

UsbSerialInterface.UsbReadCallback mCallback = new UsbSerialInterface.UsbReadCallback() {
        // Определение метода обратного вызова, который вызывается при приеме данных.
        @Override
        public void onReceivedData(byte[] arg0) {

           // data = null;
            try {
                data = new String(arg0, "UTF-8");
                // data.concat("/n");
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                            speed.setText(data);
                    }
                });

            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
    };

but the value in speed will appear for a fraction of a second and disappear, how to make the text in speed not disappear?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question