Android Question User Claims that app cannot find bluetooth device after Android 12 Update

ema01

Member
Licensed User
Longtime User
More or less what's in the title..
An user claims he can't find and connect the to our bluetooth device using our app, after the Android 12 Update. Unfortunately we don't have and Android 12 device and from what we can see there is no "support" for android 12 yet in B4A (version 11.00)

I'm quick to blame google for new changes. I've looked through the google pages and i see that there are a bunch of (new?) different permissions regarding bluetooth: starting from android 12 i should use BLUETOOTH_SCAN, instead of ACCESS_FINE_LOCATION.

But we are not using SDK31 as of yet, so what google suggests is
https://developer.android.com/guide/topics/connectivity/bluetooth/permissions said:
For your legacy Bluetooth-related permission declarations, set android:maxSdkVersion to 30. This app compatibility step helps the system grant your app only the Bluetooth permissions that it needs when installed on devices that run Android 12 or higher.

does this mean that i just have to add android:maxSdkVersion to the app, compiler, upload, problem solved?
or does maxSdkVersion mean that i can't install the app if the SdkVersion is greater than max?

Rant: Sure it feels that every new version change things for the sake of us developers having to constantly update and redo our app instead of moving on to new things.
 

DonManfred

Expert
Licensed User
Longtime User
 
Upvote 0

ema01

Member
Licensed User
Longtime User
-doesn't talk about maxsdkversion
-doesn't talk about android 12
so, you don't know?

https://developer.android.com/guide/topics/manifest/uses-sdk-element claims that maxSdkVersion won't allow the app to be installed in newer systems, while another documentation page recommends using maxSdkversion to keep using the older permission system.
 
Upvote 0

ema01

Member
Licensed User
Longtime User
Long story short,
the real issue in the end was in how we detect that location is active. We were using the "suggested" method around here, which is to use the phone library and check the content of "location_providers_allowed"
This setting has been finally removed in android 12 so to see if location is active one has to use a little bit of java.

if all is done inside and activity
B4X:
#if JAVA
import android.location.LocationManager;
import android.content.Context;

public boolean isLocEnabled() {
    LocationManager locationManager = (LocationManager) this.getSystemService(this.LOCATION_SERVICE);
    return locationManager.isLocationEnabled();
}
#End If

Dim jo As JavaObject
jo.InitializeContext
if jo.RunMethod("isLocEnabled",Null) = true then
  ...
end if

there is also a library here on the forum that wraps LocationManager but i didn't want to bother adding it to the project just for this function
 
Upvote 0
Top