Android 4.3 BTLE as server: How to start advertisements?

后端 未结 4 540
悲哀的现实
悲哀的现实 2021-02-01 06:31

I am trying to implement a BTLE SERVER on the Nexus 7 with the new BTLE API in 4.3. I am running into several problems. First there are no examples with the SDK. The only exampl

4条回答
  •  攒了一身酷
    2021-02-01 06:56

    You will need API Level 21.

    import android.bluetooth.le;
    ...
    ...
    BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    BluetoothAdapter myBluetoothAdapter = bluetoothManager.getAdapter();
    BluetoothLeAdvertiser myBluetoothLeAdvertiser =  myBluetoothAdapter.getBluetoothLeAdvertiser ();
    myBluetoothLeAdvertiser.startAdvertising (AdvertiseSettings settings, AdvertiseData advertiseData, AdvertiseCallback callback);
    

    Useful link is : https://developer.android.com/about/versions/android-5.0.html

提交回复
热议问题