Please help how can I unpair a bluetooth device with an app created in the app inventor platform

Hi all, thanks for reading and if you help me I will be so greatful towards you
well I'm new to this app inventor thing and to the coding world so please don't judge me (:slight_smile:

Ok I got the code down below from this website and I need you to tell or show me how to use it in the App inventor Blocks

the code is down below and my question is how can I used it in the code blocks
Any help will be appreciated thanks..

private void unpairDevice(BluetoothDevice device) {
    try {
        Method method = device.getClass().getMethod("removeBond", (Class[]) null);
        method.invoke(device, (Object[]) null);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

This is Java code. App Inventor uses inline blocks and extensions to build apps. If you want to use java code, you can build an extension out of it. But better say what you need, maybe there is already an extension that does what you want.

I see I have to deal with thie creation of an extension as i haven't found one.
Thanks..

What if you search BT in the community? Try it once and you won't be disappointed.

Hi @Manuel_Hernandez,
Did you manage to solve this problema from AppInventor, without the need to program an extension?

Thanks,

To unpair a device you could use the Bluetooth extension...

Taifun

Thanks @Taifun four your answer,

I apologize for omitting that my devices are BLE connected (and paired/bond).
My app forget their addresses but it doesnt remove the bond info from Android.

Thanks anyway,
Osmany

Hello Osmany, did you find something new related on this issue ? I'm also looking for a way to remove the bond of a device from my application. I would be really interested if you find something.

Hi @Waloui
I'm sorry to tell you that I can't find a solution from App Inventor blocks, so I decided to incorporate security at the application level encoding the transmitted data.

Also, I removed the pairing/bonding process and made connection through saved real MAC address of my devices; Therefore, I do a kind of bonding (only at one end, the central one) at the application level without the intervention of the operating system. At the other end (peripherics) only one simultaneous connection is allowed (no whitelist used).

For my application, these solutions work. I'm sorry I can't help.

Osmany

1 Like

You can use Bluetooth extension of Taifun.
Or this one

Thanks for the reply, but like Osmany I'm working with BLE devices so I don't think BT extension will work.

Some features will work.

1 Like

You were right it works perfectly for what I want to do.
Thanks,
Waloui.