在我的Android应用我从BLE设备接收数据,就像这样10100201201511(它包括日期,时间和其他属性)。
In my Android app I receive data from my ble device as something like 10100201201511 ( it includes date,time and other attributes).
我希望我接受它作为一个字符串,我要检查的价值和TextView中显示。
I hope I received it as a string, I want to check that value and display it on textview.
我的要求是
If (position1=0){
//display yes in Text view
}else
{ // display No in Textview
}
不过,我总是得到这样数组类型预期的错误;发现'java.lang.String中
我目前的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);
if (names[0]=0){
line1.setText("got it");
}
else{
line1.setText("Nil");
}
PLZ帮我解决这个..
Plz help me to resolve this..
我想在名称出现错误[0] = 0
,因为名称
是一个字符串。
I assume the error occurs at names[0]=0
because names
is a string.
如果你想读的字符串中使用的第一个字母
If you want to read the first letter of the string use
if ( !names.isEmpty() && names.substring(0,1).equals("0"))
line1.setText("got it");
else
line1.setText("Nil");
上一篇:编辑modalpopup内一个gridview不关闭弹出弹出、编辑、modalpopup、gridview
下一篇:无法打开一个SQL Server 2000 DTS包我导入到SQL Server 2008无法打开、导入到、SQL、Server