Jump to content
mbest

Android 12, Delphi 11.3 Bluetooth

Recommended Posts

I have been using Delphi for a while and decided to take the plunge with Android, specifically BlueTooth. I have an issue and I think it's permissions and linked to BLUETOOTH_SCAN. I have tried several "fixes" out there but, to be brutally honest, I'm not yet familiar with the environment to the point that a) I know what the issue is and b) if it's a case of Android 12 isn't supported (it wasn't 12 months ago)?

 

Any pointers on how to progress (I don't want to throw the towel in yet) would be very welcome. This is the project I am trying to follow https://subscription.packtpub.com/book/programming/9781800203822/14/ch14lvl1sec99/starting-with-bluetooth-classic and it fails as soon as I enable Bluetooth. I am going to borrow an older Android device next week to see if the problem is the changes in security/permissions.

 

Thanks, mb

Share this post


Link to post

Hi

 

Thanks for that Brian, the error is black screen if I try and make Bluetooth active on form create and the app loads if I don't :) I have done some more reading over the weekend and will start again basing my approach on one of the sample apps supplied. If it works I will get there in the end. I was expecting "it's a known issue" or similar as I have yet to find a working bluetooth example for Android.

 

All the best, mb

Share this post


Link to post

I have taken another go at this using the demo app C:\Users\Public\Documents\Embarcadero\Studio\22.0\Samples\Object Pascal\Multi-Device Samples\Device Sensors and Services\Bluetooth\Classic Bluetooth Basic app

 

With 11.3 and Android 13 the error is "java.lang.SecurityException: Need android.permission.BLUETOOTH_SCAN permission for android.content.AttributionSource@69f00117: AdapterService isDiscovering."

 

I get that, BT is now on the dangerous list but I can not find a way of fixing it.

 

All the best, mb

Share this post


Link to post
5 hours ago, mbest said:

I get that, BT is now on the dangerous list but I can not find a way of fixing it.

Take a look at the ScanFilterServicesAdvData demo in the same folder, specifically TForm6.Button1Click in Unit6.pas. It shows how to request permissions, including the one you need.

  • Like 1

Share this post


Link to post

Many thanks for that Dave, I will do that.

 

All the best, mb

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

×