Jump to content
Rollo62

Howto handle Android BluetoothLE permissions that are compatible to API29,30,31 ?

Recommended Posts

Hi there,

 

I was experimenting with the Android.template.xml, to use different API-related selections, to searate old and new Bluetooth settings.

Some recommendations in the web point to this nice and clean solution, so separate APIs in the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="...">

    <uses-permission android:name="android.permission.BLUETOOTH"
                     android:maxSdkVersion="30" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
                     android:maxSdkVersion="30" />

    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
                     android:usesPermissionFlags="neverForLocation" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

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

    <application ... />

</manifest>

Using the android:maxSdkVersion and the android:usesPermissionFlags="neverForLocation" identifier would allow an easy control over different versions.

Unfortunately this didn't work in my current setup, maybe I have to rry again with a clean project, but I see a failure "attribute neverForLocation is not available".

This seems that targeting to API31 is needed, and I'm still under API30, in its D11 default setup.

 

But I'm not sure why this message pops up, and is not simply ignored, if there is an unknown attribute.

Probably this needs linked somehow to the API31, and API30 throws exception.

To be rescued, maybe the android:maxSdkVersion might work under different versions in different configurations, to make Delphi compatible with several API's at the same time in one manifest ?

 

To be clear, I'm not talking about the targetSdkVersion here, but if someone could make use of the  android:maxSdkVersion attribute already.

 

I'm curious if somebody has get this working as expected under Delphi.

 

Beside that, what would be the best way to handle BluetoothLE under API30, to be compatible with old and new devices ?

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×