How am I able to display data read from BLE device on android?

I am new to android studio and am able to receive the following data in Logcat but now need to be able to see that data in the app.

How am I able to change this code to do that?

@Override
        public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
            super.onCharacteristicChanged(gatt, characteristic);
            byte[] value = characteristic.getValue();
            Log.i("BLE", "receive value ----------------------------");
            for (int i = 0; i < value.length; i++) {
                Log.w("BLE", "character_value = " + value[i]);
            }
            //processData(characteristic.getValue());
        }

I know that to send the data to a textView on android I would use this:

((TextView)findViewById(R.id.data)).append(output);

But the .append(output) I am not sure how to configure.

I could probably use

StringBuilder output = new StringBuilder();
((TextView)findViewById(R.id.data)).append(output);

Instead of Log.i("BLE", "receive value —————————-");

But for Log.w("BLE", "character_value = " + value[i]); I am not sure since it is a string and a byte value.

If anyone could help me that would be great!

Source: Android Questions

LEAVE A COMMENT