connectivity-samples icon indicating copy to clipboard operation
connectivity-samples copied to clipboard

BleAdvertisements sample code need be updated for Android 8 and above

Open basin0809 opened this issue 4 years ago • 2 comments

For people who need run BleAdvertisements sample on Android 8 or above, below changes are necessary:

  1. add android.permission.ACCESS_FINE_LOCATION to manifest, and ask run time permission for it.
  2. add android.permission.FOREGROUND_SERVICE to manifest, otherwise app would crash once it starts advertising service.
  3. Create a notification channel for the advertising service, otherwise startForground() will complain bad notification and crash the app.

basin0809 avatar Aug 27 '20 22:08 basin0809

Yo also have to change Notification.Builder(Context context) to Notification.Builder(Context context, String string)

Notification.Builder documentation

Y3hu avatar Sep 11 '20 17:09 Y3hu

We have provided a Kotlin version that is up to date: https://github.com/android/connectivity-samples/tree/main/BluetoothAdvertisementsKotlin

isaidamier avatar Jun 24 '21 17:06 isaidamier