Read the original article:How to Open Bluetooth Settings via App Linking
Question
How can I use App Linking to open the system Bluetooth settings for pairing?
Short Answer
Call startAbility() with a Want targeting the Bluetooth settings URI (bluetooth_entry) in the system settings app.
Applicable Scenarios
When your app needs to redirect users to the Bluetooth pairing interface—commonly used in smart device or accessory setup flows.
Code Example
let context = getContext(this) as common.UIAbilityContext;
let want: Want = {
bundleName: 'com.huawei.hmos.settings',
abilityName: 'com.huawei.hmos.settings.MainAbility',
uri: 'bluetooth_entry'
};
context.startAbility(want)
.then(() => {
console.info('Bluetooth settings opened');
})
.catch((err: BusinessError) => {
console.error(`Failed to open Bluetooth settings. Code: ${err.code}, message: ${err.message}`);
});
Key Takeaways
Use startAbility() with a Want that targets the system settings app’s bluetooth_entry URI to open the Bluetooth pairing screen. This is useful for guiding users directly to Bluetooth settings during device setup.
Top comments (0)