पर काम नहीं कर रहे लक्षण पढ़ें मैं लगातार एक बीएलई डिवाइस से विशेषताओं को पढ़ने की कोशिश कर रहा हूं।एंड्रॉइड ब्लूटूथ LE - सैमसंग
मैं अपने सेवा कक्षा में एक Runnable बनाया है:
private class BackgroundRunnableForRead implements Runnable
{
private volatile boolean isRunning = true ;
@Override
public void run() {
try {
BluetoothLeService.this.backgroundRunID = Thread.currentThread().getId();
while(isRunning) {
List<BluetoothGattService> gattServices = BluetoothLeService.this.getSupportedGattServices();
if (gattServices != null && gattServices.size() > 0) {
BluetoothGattCharacteristic characteristic = getCharacteristic(gattServices);
if (characteristic != null && (characteristic.getProperties() & 2) > 0) {
BluetoothLeService.this.readCharacteristic(characteristic);
}
}
}
}
catch(Exception e)
{
isRunning= false;
e.printStackTrace();
}
}
public void kill()
{
this.isRunning = false;
}
}
और सेवाओं की सफल खोज पर मैं बोल रहा हूँ:
public void startReadingCharacteristics()
{
System.out.println("BluetoothLeService.startReadingCharacteristics");
this.mBackgroundRunnable = new BackgroundRunnableForRead();
mReadThread = new Thread(mBackgroundRunnable);
mReadThread.start();
}
और यह characterics पर मेरी कॉलबैक पढ़ा है -
public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic,
int status) {
System.out.println("BluetoothLeService.onCharacteristicRead" + status);
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
}
}
एप्लिकेशन नेक्सस 5, नेक्सस 4 और मोटोरोला जी पर ठीक काम करता है।
जब मैं सैमसंग एस 6 पर यह कोड चला रहा हूं तो यह काम नहीं करता है, onCharacteristicRead()
नहीं कहा जाता है।
मैंने पढ़ा है कि readCharacteristics()
पर अनुक्रमिक कॉल करने से समस्याएं उत्पन्न हो सकती हैं क्योंकि यह निष्पादित करने के लिए आवश्यक है।
ओएस संस्करण क्या है? –
ओएस संस्करण - एंड्रॉइड 5.1.1। – Anukool
कृपया अपना कोड –