Android-Proximity-SDK icon indicating copy to clipboard operation
Android-Proximity-SDK copied to clipboard

Proximity is not working on Android 11

Open mayurvashishtha opened this issue 4 years ago • 1 comments

Prerequisites

  • [X] Put an X between the brackets on this line if you have done all of the following:
    • My beacons have Estimote Monitoring enabled (Check it in the Estimote Cloud, or via app)
    • My Android device/devices supports BLE and has Android OS version >= 5.0.0
    • My Android device/devices have bluetooth enabled
    • My app has Location Permissions granted

Basic information

Estimote SDK version: com.estimote:proximity-sdk:1.0.5, com.estimote:scanning-plugin:0.25.4

Android devices affected: SM-G975F/DS

Android OS version affected: Android 11

Beacon hardware version: J1.9_B1.1

Description

Proximity is not working on Android 11

Expected behavior: It should detect onEnter(), onExit() events

Actual behavior: Not working

Additional information

Add here any logs you want to attach, or any other info, like pictures for example

mayurvashishtha avatar Apr 05 '21 11:04 mayurvashishtha

I've managed to get proximity working on an app targeting API 30 (Android 11)

Steps I took to fix this were

Ensure I had "fine" location permissions granted at runtime + included in app manifest

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

Ensure I had granted location permissions to the Estimote foreground service Android API 29+ appears to require an explicit declaration for foreground services that access specific permissions https://developer.android.com/guide/components/foreground-services#loc-camera

I appended this service to my android manifest (basically de-compiled my own app to extract the merged manifest, then extracted the estimote service declaration and appended the foregroundServiceType attribute)

   <service android:enabled="true" android:exported="false" android:name="com.estimote.scanning_plugin.packet_provider.service.PacketProviderWrapperService"
       android:foregroundServiceType="location"/>

This is working for me, both with the UI in the foreground and with the UI in the background (with running notification / foreground service)

Tested on Pixel 6 (Android 12) + Pixel 3 XL (Android 11)

Hope this helps!

daniel-cotton avatar Nov 03 '21 11:11 daniel-cotton