Need Help In Bluetooth Permission for an app on Android 12

Really new problem for me also .
running Android12 with BLUETOOTH_SCAN askForPermission when permissionName= BLUETOOTH_CONNECT.
. Changed recently after a new apk build on AI.

Evan Patton (MIT Guru) is looking into this issue.

Some guidance from Evan, but note this is not the official solution, a sample file is needed from one of you guys for studying at MIT:

Bluetooth Classic only (the Blocks that are integrated within App Inventor, not an extension (BLE))

Android 11 and below
BLUETOOTH and BLUETOOTH_ADMIN permissions.

Android 12+
BLUETOOTH_SCAN + BLUETOOTH_CONNECT permissions for clients and BLUETOOTH_ADVERTISE permission for the server component.

may be some indication for you here ?

Bluetooth permissions

I think the main thing we need to understand is what are people in this thread doing differently from a standard flow. We are following the Bluetooth permission guidelines published by Google, as linked above by @_Airsig3d. Specifically, in Android 12 and later Bluetooth permissions are moved to a runtime model where the app asks for permission from the user. App Inventor will automatically perform request the permission when certain methods in the BluetoothClient/BluetoothServer components are called (AcceptConnection, Connect, etc.).

BLUETOOTH_ADVERTISE is for Apps that are setup to be the Server. Usually, the device (e.g. microcontroller such as Arduino) is the Server and the App is the Client.

We really need to see your Project file to understand more about the issue

Project (.aia) to PC
Export Project

Upload to Forum Post
UploadToTopic

Hello All,
I am trying to search of BT devices and connect BT device from the list. But getting error 908 BLUETOOT_CONNECT permission.

Android version: 12
Using Bluetooth LE

Please go through the code blocks and help.

Here is a simple example (extract of one bigger program) to demonstrate the problem
When you will try to connect to a BT device , you shoudl have the problem .
Once again this is very new and was not there a few days ago.

TestBTConnect.aia (425.6 KB)

Hello Sudarshan

Please see my post #4, you are not asking for enough permissions (location is required). When prompted, I assume you allow them? Or is the prompt not popping up?

Hi Chris,
I have given permission.
But can you help with steps to give permissions (link)

Also can u send link of your post#4

Thanks in advance

Hello Airsig3d

Your code is not requesting the permissions stated in my post#15.

  1. What is your phone's Android version?
  2. What is your phone's Bluetooth version?
  3. What is the target device's Bluetooth version?
  4. Are you checking that Bluetooth is switched on (both devices)?

The code is also chopping out the address part of the device address (without verifying success) - yet that is unnecessary, you can just use the address as-is.

Hi again Sudarshan - sorry, I didn't notice this was your first time on the forum - Welcome!

Your post in this topic is #21; scroll up to see my post#4.

What is the version of the BLE Extension you are using?

Can't see enough of your code to know if it is correct.

There isn't really a need to have a button for every stage of the process - when one stage is complete, it can auto-start the next.

  1. What is the Bluetooth version of your phone?
  2. What is the Bluetooth version of your target device?
  3. Are you checking that Bluetooth is switched on (both devices)?

I note the distinct lack of UUID's. What exactly does your Project do?

Note that with the latest release BLE will be broken even with the workaround people have been using of adding a BluetoothClient component. This is because the permissions are now selectively applied. I'm working on an updated version of BLE that is compatible with Android 12.

2 Likes

Hello Everyone - if you are using BLE with Android 12, please note Evan Patton's post#25. You will need to wait for an extension update, or use a phone with Android 11 or below.

Muchas gracias y suerte con la solución

Hi Chris
I am using android12 phone + BT classic for both my phone and the device and my BT are switchon .
As Akash in post#7 , al was allright a few days ago .
I change slighly the permissions and I have now :

but this big problem is still there ,
thanks

Try this (Companion & APK):

What exactly are you trying to connect to? You have not answered my questions in post#23.

Just to clarify more, you are running an Android 12 phone, it is probably using BLE.

Hi Anke

I simplify my aia to avoid confusion, and tried your solution. I can confirm that I am working on API 31 and Android12.
The problem occured exactly when I ask the Bluetoothclient.connection with the correct adress
TestBTConnect.aia (423.2 KB)
:

Hi
this is Strange.
I just tested now my aia on another phone, with exactly the same caracteristics ( API31/ android12) but its works!
the only difference is that this phone asks me the "autorisation to detect other device nearby" once , where the first phone doesn't ask .
Itr come then effectivelly from the server side ...

As mentioned before, there is no need to split-up the address - this might be the cause of your issue.

Further down the line there will likely be more issues but we cannot help you if you are unwilling to answer our questions.

That may be a forgiving 'developer mode'.