How to extract a bit from a byte and display it on a textview, in Android? -


i receiving string data ble device. stored in string names need extract byte eighth position, need extract bits byte.

how can achieve this?

now, able receive string . , im able extract first 2 sub strings.

my current code :

@override public void oncharacteristicread(bluetoothgatt gatt,                                  bluetoothgattcharacteristic characteristic, int status) {     if (status == bluetoothgatt.gatt_success) {         if (bleuuid.read_time                 .equalsignorecase(characteristic.getuuid().tostring())) {             final string names = characteristic.getstringvalue(0);               runonuithread(new runnable() {                 public void run() {                     statuslv.settext("status received..");                     setprogressbarindeterminatevisibility(false);                     if ( !names.isempty() && names.substring(0,1).equals("a")){                         line1.settext("got it");                     }                     else{                         line1.settext("nil");                     }                     if ( !names.isempty() && names.substring(1,2).equals("a")){                         line2.settext("got again");                     }                     else{                         line2.settext("nil again");                     }                   }             }); 

use string.getbytes( charsetname ) if want extract bytes of string.

please post relevant code.


Comments