Connexion bluetooth with Arduino: problem between companion and .apk

Hello,

i make an app to communicate with an arduino with an HC06 bluetooth module.

My app is working well with companion but not when it is in an .apk...

do you know this problem?

Communication_tablette.ino (979 Bytes)

Can it scan and connect?

yes, everything is ok with compagnon
with the compagnon
scan show the list of bluetooth device
App connect and send information text to arduino
I see the result in the serial monitor

but when i get the .apk
the scan don't show the device bluetooth ...

thanks for the interest you give to my question !

The .apk is a different app from the Companion, in Android's eyes.

So it needs its own Permissions.

(Canned Response ABG - Bluetooth non-BLE SCAN Permission Blocks)

The easiest solution, for immediate relief
(from @Barry_Meaker) ...

I had the same issue. The problem is your app does not have permission to see nearby devices. The solution is to give your app permission on your phone (no code changes in your app).

on your phone,

  • goto settings
  • search for your app
  • in App Info for your app select Permissions
  • change Nearby Devices from Not Allowed to Allowed
  • Done

By the way, the very first time you run the app, Android will ask if you want to grant the app this permission. If you say no, or ignore the pop-up, the permission will be set as Denied. Android will not ask again.

A more complex approach, for professional app development:

See Bluetooth liste of devices deosn't work anymore - #7 by Anke
Special note for Xiaomi devices:
I have an error with bluetooth on android 12, Xiaomi Poco X3 NFC - #20 by Patryk_F

...

1 Like

Hello ,

That works,
you are awesome

my next experiment is to send data from arduino to my apk
I will tell you the result!

best regards