0

I have a humidity sensor that broadcasts the last ten values as a single array after a fixed time interval. I want to display these values in ten Textview's.

My current code displays all the values in a single TextView, how can I modify this? How could it possible?

@Override
public void onCharacteristicRead(BluetoothGatt gatt,
                                 BluetoothGattCharacteristic characteristic, int status) {
    if (status == BluetoothGatt.GATT_SUCCESS) {
        if (BleUuid.READ_SENSOR
                .equalsIgnoreCase(characteristic.getUuid().toString())) {
            final String values = characteristic.getStringValue(0);
            byte[] bytes =values.getBytes();
            final String value = new String(bytes);

            runOnUiThread(new Runnable() {
                public void run() {
                    statuslv.setText(value);
                    setProgressBarIndeterminateVisibility(false);
                }
            }); 
Mr Robot
  • 1,747
  • 6
  • 35
  • 67

1 Answers1

1

Split up the String you receive.

Depending on the format, you should be able to use something like this

String[] parts = string.split(","); //this should use the character(s) which separate your results

If you really want to show the results in 10 different TextViews, then you can do

textView1.setText(parts[0]);
textView2.setText(parts[1]);
//...

You could also put the results in a ListView.

SnyersK
  • 1,296
  • 8
  • 23
  • My received String is final String value = new String(bytes); But how will i split the String value that contains my data for checking with if else – Mr Robot Jul 17 '15 at 07:31
  • If this is a new question, please open a new question or edit your existing one. – SnyersK Jul 17 '15 at 08:06
  • yes. i done http://stackoverflow.com/questions/31470865/how-will-i-split-a-string-that-received-from-a-ble-device-for-if-else-checking-a?noredirect=1#comment50907405_31470865 – Mr Robot Jul 17 '15 at 08:08