my.onBluetoothDeviceFound().
Parameters
Code Example
Remove All Listeners
Remove Specific Listener
Complete Cleanup
Related APIs
my.onBluetoothDeviceFound
Listen for devices
my.stopBluetoothDevicesDiscovery
Stop discovery
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Stop listening for Bluetooth device discovery events.
my.onBluetoothDeviceFound().
| Property | Type | Required | Description |
|---|---|---|---|
| callback | Function | No | The specific callback to remove. If omitted, all listeners are removed. |
my.offBluetoothDeviceFound();
Page({
onLoad() {
my.onBluetoothDeviceFound({
success: this.handleDeviceFound
});
},
handleDeviceFound(res) {
console.log('Devices found:', res.devices);
},
onUnload() {
my.offBluetoothDeviceFound(this.handleDeviceFound);
my.closeBluetoothAdapter();
}
});
Page({
onUnload() {
// Stop discovery
my.stopBluetoothDevicesDiscovery();
// Remove listeners
my.offBluetoothDeviceFound();
my.offBluetoothAdapterStateChange();
// Close adapter
my.closeBluetoothAdapter();
}
});