BLE 4.0 getting the broadcast data from device to phone

后端 未结 2 1888
Happy的楠姐
Happy的楠姐 2020-12-11 08:55

\"enter

I have two devices. one Android phone with API level more than 18 and other is

2条回答
  •  Happy的楠姐
    2020-12-11 09:04

    saw your email, I think you are somehow connected via Bluetooth classic, but are then attempting to 'chat' on BTLE protocol.

    That's the problem. There is almost no way an Android 4.0 device has BTLE.

    Even if it has an BTLE chip(there was some early Motorola phones with BTLE - you had to import a .jar from Motorola Inc.), it wouldn't use the Android BTLE API you seem to use.

    So to make a long story short, you should either be using Bluetooth Classic (SPP) with the normal BluetoothSocket, or be using two Android BTLE devices.

    Here is how to check if the devices have BTLE:\

    If you want to declare that your app is available to BLE-capable devices only, include the following in your app's manifest:

    However, if you want to make your app available to devices that don't support BLE, you should still > include this element in your app's manifest, but set required="false". Then at run-time you can determine BLE availability by using PackageManager.hasSystemFeature():

    // Use this check to determine whether BLE is supported on the device. 
    // Then you can selectively disable BLE-related features.
    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
        Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
        finish();
    }
    

提交回复
热议问题