Issue with Handling Bluetooth Pairing Errors

Hey, this is my first post related to MIT App Inventor.

I'm having trouble handling errors when pairing via Bluetooth. I created an app that connects to an ESP32 via Bluetooth, but I ran into an issue:

If I select a device from the list of paired devices, but it's unavailable (turned off or out of range), Android returns an application error and expects it to close (even though the app is still running). I tried adding error handling—redirecting the user to another screen in case of an issue—but the app still crashes.

Does anyone know how to properly catch this error and prevent the app from crashing? Thanks in advance!

This sounds like you get a runtime error.... you can't catch runtime errors...
What is the manufacturer and Android version of your device? What happens on another device?
You might want to provide a screenshot of the error message

Taifun

I have tried on various versions of Android, both the latest and older ones, and on different phone brands such as Samsung, Xiaomi, and Ulefone.

nie odpowiada – it either freezes, waits, or closes.

esp32 not responding

Close application

Wait

Unfortunately I do not have more ideas ... probably someone else?
Taifun

Dear @Krystian_Szymanski ,
please have a look to this post:

You'll find therein a couple of codes (app and ino) that were working for me. Probably they can help.

Hey, thanks for your response, but my issue is a bit different. If the device is nearby, I have no problem pairing with it. The problem occurs when the device I am paired with is not available (for example, if it has been disconnected from power).