Available blutooth devices not showing

I created an app which is used to connect to bluetooth module hc-05 but my app didn't even showing available blutooth devices. With the same code that previously executed i created a new one but after installing the code was not showing bluetooth devices.

This user just posted what worked for him for adding permissions to BlueTooth.

Could you try it and tell us if it worked for you?

Hello Dhanush

Welcome to the grey hair club :grin:

In your code
Replace this:

With this:

Or This:

In your code, I can't see devices being scanned for? It is best to give the scan a bit of time to complete, so put the Block in a Clock Timer. Same for Connect.

Set the Clock Timer intervals in the Blocks where you can tweak them easily while running your App on your Device (phone) via the Companion.

Make sure your phone and the device you wish to connect to have Bluetooth switched on. Your phone may need to have Location switched on too, depending on Android version. It's a Google Android security measure, I just switch it on regardless of which Android version I'm using.

2 Likes

Thanks but it's not working. Is mit app inventor facing any issues.

My guess is, you did not follow the advice from @ABG and without asking for necessary permission it will not work...

Taifun

Expanded boiler plate:

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

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

You also will need to pull in TinyDB into your project.



When Permission Granted (@Patryk)

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.

(Thanks to @Patryk_F for correction to grant order)
Special note for Xiaomi devices:

Thank you very much fellow. Now it's working.

Which road did you take?

  • the easy road
  • the hard road

the easy one buddy

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

Possible typo in API level procedure call

This answer seems to have a typo in the API level procedure.

It will return an API level of 3 for Android 11 instead of 30 as shown in the list:

1.0,1\n1.1,2\n1.5,3\n1.6,4\n2.0,5\n2.0.1,6\n2.1,7\n2.2,8\n2.2.1,8\n2.2.2,8\n2.2.3,8\n2.3,9\n2.3.1,9\n2.3.2,9\n2.3.3,10\n2.3.4,10\n2.3.5,10\n2.3.6,10\n2.3.7,10\n3.0,11\n3.1,12\n3.2,13\n3.2.1,13\n3.2.2,13\n3.2.3,13\n3.2.4,13\n3.2.5,13\n3.2.6,13\n4.0,14\n4.0.1,14\n4.0.2,14\n4.0.3,15\n4.0.4,15\n4.1,16\n4.1.1,16\n4.1.2,16\n4.2,17\n4.2.1,17\n4.2.2,17\n4.3,18\n4.3.1,18\n4.4,19\n4.4.1,19\n4.4.2,19\n4.4.3,19\n4.4.4,19\n4.4W,20\n4.4W.1,20\n4.4W.2,20\n5.0,21\n5.0.1,21\n5.0.2,21\n5.1,22\n5.1.1,22\n6.0,23\n6.0.1,23\n7.0,24\n7.1,25\n7.1.1,25\n7.1.2,25\n8.0,26\n8.1,27\n9,28\n10,29\n11,3\n12,31\n12.1,32\n13,33\n14,34

Might save a bit of head-scratching for someone.