Android 12 no list of Bluetooth devices, error 908

I'm installing my app on a Samsung phone with Android 12,

and I can't turn on the Bluetooth connection
(In phone settings, Bluetooth switch is enabled.)
first after launching the mobile app,
(Mobile program created on a regular AI2 server)
connection should automatically occur,
but it shows 503 error,

and when I want to open the list of bluetooth devices it gives me error 908 .

I see a lot of repeated questions in the forum with this error,
but I don't find a solution to fix bugs if android version >10.

The program for which I now have a question does not connect to Android 12.
But at the same time, it works fine with another phone running Android 7.

On Android 7, this program has a Bluetooth connection,
and there is a list of bluetooth devices.
Here is a photo on Android 7, a list of these Bluetooth devices.

On Samsung phone with Android 12, this list is not there,
instead of the list, error 908...
How can I fix this?
Do I need to make separate settings for Android 12?

BluetoothClient or BLE?

Try this:

1 Like

With your BluetoothBLE program, I have a list of devices open.

My Bluetooth SPP module is used in arduino.
There is no device list in my program XY_Bat_Stat_APK.rar - Google Drive

Try this one:

1 Like

A list of Bluetooth SPP devices is displayed.

In my program, it should be exactly like this.
but instead of the list I get error 908

I create my program from the standard BluetoothClient blocks
Where does this error 908 come from?

You must request permission. I'll show you when I'm back at home.

1 Like

You need to ask for permission before scanning for devices.


1 Like

I have a question, where did the GetASD1-SdkVersion block come from?

My block is .PermissionGranted
on error 503 or 908 nothing returns any value in permissionName

Therefore, I had an idea to make it in such blocks
blocks (1)
in my project it worked (select list appeared).
What do you think, such a solution with the .ErrorOccurred block
Will not interfere with other, smaller versions < than Sdk31?

Error 503: The specified address is not a valid Bluetooth MAC address

For me, it does not make sense to ask for bluetooth scan permission after getting that error... why not asking for permission before connecting?


1 Like

Here: Get the path of → ASD (app-specific dir) & → private data dir (internal storage)
or: Get the API Level of the device

The permission (BLUETOOTH_SCAN) does not exist on Android < 12. So you will see an error ("Error 908") after requesting it on Android < 12.

How about doing it exactly as I showed?

Thank you very much for your efforts Anke. This is working.
When I open the program for the first time (on an Android 12 phone), it asks for Bluetooth permission.
But the device list is not available yet,
then I make the second launch of the program (on an Android 12 phone) there are no problems in the program anymore, everything works fine.
Please tell me, I made a decision of the blocks, in this form
blocks (2)
Will this be a complete fix for the problem?
after all, in this form, the permission (BluetoothConnect, BluetoothScan) for Android 12 will be initialized each time the program is opened, while, as I understand it, the permission is already somewhere in the phone’s cache.
Is it permissible to constantly make permission, as in the example of my blocks?
(I'm sorry, due to the incorrect description, I use an automatic translator to communicate with you :))

And again:

:thinking: :woman_shrugging:

1 Like

I think I got your advice
and figured out how it works :+1:

Once again, thanks for your patience.
The error in my program is fixed!

P.S. It became interesting
I searched for answers to my questions on the Internet,
turns out,

  @SimpleProperty(description = "The SDK version of the software currently running on this hardware device. Версія програмного забезпечення SDK")
  public int SdkVersion() {  return android.os.Build.VERSION.SDK_INT;}
I can also add such a block to my set of blocks.

Thank you, I will continue to use this.


After that,
as you explained to me
what is my problem.
I added these blocks to my extension.

Now I'm in my "mathematics", I can always use these functions.
Thank you, my issue has been resolved.

Don't understand what it's about.
Btw, it's no problem to do without any extension:

1 Like

apiLevel.aia (2.2 KB)

See also here: Android Versions Resource CSV