for receiving data from arduino
UsbSerialInterface.UsbReadCallback mCallback = new UsbSerialInterface.UsbReadCallback() { //Defining a Callback which triggers whenever data is read. @Override public void onReceivedData(byte[] arg0) { String data = null; try { data = new String(arg0, "UTF-8"); data.concat("/n"); tvAppend(textView, data); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } };
and send data from arduino
serialPort.write(string.getBytes());
check out the full tutorial
source share