How to make the "Switch Button" to enable Phone's Bluetooth when toggled?

Hello my dears,

I am trying to enable my phone's bluetooth module from inside the app that I am currently working at.

I have used a "Switch Button" that I want to press whenever I open the app, in order to activate the phone's bluetooth.

Screenshot_18

The problem is, I can't seem to find out how to do that.

These are the blocks I currently have for the switch which don't work at the moment.

Screenshot_17

I must say that I didn't compiled the apk from the project, I simply used the companion app from the playstore and toggled the switch through it to see if the phone's bluetooth is turning on and it didn't.

Screenshot_19

I don't know if that is the way testing has to be done, I am very new to programming and to MITAI 2.

Also, from what I've found after some google searching is that in Android Studio, for example, there is a class called Bluetooth.Adapter (or something similar) which seems to be what needs to be used for playing around with the bluetooth's on/off state. Sadly, I didn't find any resource for MITAI 2 in regards to this subject.

Thank you!

Hello MelodyApril

It's a good idea to search the Forum for "Bluetooth" - you will find plenty of examples.

It is normal practice to enable your phone's Bluetooth via your App on App startup, no switch or button required, using Activity Starter:

IsBluetoothEnabled.aia (3.0 KB)

See my website for info on Bluetooth and lots more:
https://www.professorcad.co.uk/appinventortips#TipsBluetooth

Note: An App would not normally be used to switch off Bluetooth - that's up to the User, who may be using other Bluetooth enabled Apps too. It's particularly important at this time as millions of people have a background App running for Covid-19 Track and Trace.

Thank you guys.

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