0
我正在使用android的Bluetoothgatt示例應用程序。該設備已連接,但bluetoothdevice.getname()返回null。這隻發生在micromax手機上。 (它有Kitkat os和藍牙4.0支持)。有沒有解決方案來讀取設備中的數據?我可以在其他手機上獲取設備名稱和其他特徵。ble device bluetoothdevice.getname()返回null
我正在使用android的Bluetoothgatt示例應用程序。該設備已連接,但bluetoothdevice.getname()返回null。這隻發生在micromax手機上。 (它有Kitkat os和藍牙4.0支持)。有沒有解決方案來讀取設備中的數據?我可以在其他手機上獲取設備名稱和其他特徵。ble device bluetoothdevice.getname()返回null
請嘗試以下代碼。
public class BLEStateReceiver extends BroadcastReceiver {
String action = intent.getAction();
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if(device!= null && device.getType() != BluetoothDevice.DEVICE_TYPE_LE)
return;
if(action.equalsIgnoreCase(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
int extra = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, 345);
switch (extra) {
case BluetoothDevice.BOND_BONDED:
BluetoothDevice bondedDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if(bondedDevice!= null) {
Log.d("TAG", "Bonded device name = " + bondedDevice.getName() + " Bonded Device address ="+bondedDevice.getAddress());
}
break;
}
}
我試過的代碼,但什麼也沒有發生,我認爲我不能夠使用正確的代碼可以請你指導我我也看到了這個11月8日至27日:15:12.054 11913-11913/com。示例。 android.bluetoothlegatt E /:appName = com.example.android.bluetoothlegatt,acAppName =/system/bin/surfaceflinger 08-27 11:15:12.054 11913-11913/com.example.android.bluetoothlegatt E /:0在我的登錄貓 –
也我想知道的是bluetooth a2dp強制讀取和寫入數據到設備 –