Android 12 no list of Bluetooth devices, error 908

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.

2 Likes

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?

Taifun

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:
2023333

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.

:question:

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

2 Likes

(Canned Response)
These blocks can be dragged into your Blocks Editor to request permission(s) for Bluetooth scanning and connecting. All three parts are needed.




Thanks to @Anke for the original code.
My changes include

  • use of the Screen1 permission blocks to avoid the possibility of a typo
  • using a TinyDB tag particular to BT permissions and only for BT permissions.
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.