Finding Code Blocks from MIT 1 in MIT 2 (how to pair bluetooth devices)

This is my own button that I created for the pairing process and I need to take the pairing code from that tutorial and add it into my project, I took what I could but having problems with the said above "call length" and "call segment" things which I don't know how to find the call function for them in MIT 2. And besides from that I don't exacly know which part of the code from the tutorial is for the pairing process but that's okay I'll figure it out but I need to find a way to manage to call length and segment in my code as well until then.

And how do I call that length segment ? If you look into the MIT 1 code it is being called.

this snippet will not pair the devices, but will open the settings for the user to do the pairing manually
if you want to do that, just use the activity starter with the following settings

  • Action = android.intent.action.MAIN
  • ActivityClass = com.android.settings.Settings$BluetoothSettingsActivity
  • ActivityPackage = com.android.settings

as mentioned in that tutorial...
to programmatically pair devices, you will need an extension, see your other thread

Taifun

You don't name it. You just take it and drag it.

My dear, thank you for your clear answer. I don't mind the procedure, so that's why I want to implement it like this for the moment.

So, I did just that for the Activity Starter, I also added the following blocks for the button code:

Screenshot_9

Screenshot_8

The problem is that, when I press the pair button on my phone, I get the following error:

Error Number: 601
Message: No corresponding activity was found,
Function:StartActivity
Component: com.google.appinventor.components.runtime.ActivityStarter@xxxxxx

You might use this extension which supposedly can pair devices, Now this extension is free to everyone----see the bottom part of the discussion of the extension.

2 Likes

this is the correct Action
android.intent.action.MAIN
i.e. remove the "Action =" same for the other items

Taifun

1 Like

Wow, thank you very much for your answer, I will check the extension out as well, that's great news my dear!

In my applications I use this:

Opening BT settings:

A request to enable BT:

1 Like

Thank you dear, works like a charm now!

From the conversation I understand that you need to pair with a BT device, knowing its address and name without going to the settings?

Thank you very much for the snippets, very useful example for us beginners especially right there!

Yup, that is the ultimate goal my dear.

At the moment I got it working by making the Pair Button to get me to the BT settings menu thanks to Taifun's advice!

I will also check that free Bluetooth Extension that @SteveJG recommended, that may be the key to achieve my goal. As for now, I am very happy with the results I got in such short time with your help guys, could've take me weeks to figure all this new stuff out by myself. Hope this thread will also help other beginners looking for answers out there now and in the future :slight_smile:

Why does my activity with "one" block work the same as your activity with three blocks?

This extension works. Unfortunately, it requires location permissions, which may arouse suspicion and aversion to the application.

No problem for me, since the app I am working at is supposed to meassure distance between my phone and the esp32 device my dear. But I guess you can take a look into the blocks, check where the blocks that ask for location are placed and delete them (also check if there is any activity module that is used to ask for location permission) my dear.

Yes, that's true.
Latest versions of android want your app to have location permission to search for nearby devices.

this is not "my" activity... this was mentioned in that old tutorial...
and in doubt use the solution, which requires less blocks, in this case your method...

Taifun

Briefly, I just called "mine, yours" so you know what's going on. This one line works, for sure on Android 8, 9 and 10.