Share via


BluetoothDevice.SetAlias(String) Method

Definition

Sets the locally modifiable name (alias) of the remote Bluetooth device.

[Android.Runtime.Register("setAlias", "(Ljava/lang/String;)I", "", ApiSince=31)]
[Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")]
public int SetAlias (string? alias);
[<Android.Runtime.Register("setAlias", "(Ljava/lang/String;)I", "", ApiSince=31)>]
[<Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")>]
member this.SetAlias : string -> int

Parameters

alias
String

is the new locally modifiable name for the remote Bluetooth device which must be the empty string. If null, we clear the alias.

Returns

whether the alias was successfully changed

Attributes

Remarks

Sets the locally modifiable name (alias) of the remote Bluetooth device. This method overwrites the previously stored alias. The new alias is saved in local storage so that the change is preserved over power cycles.

This method requires the calling app to be associated with Companion Device Manager (see android.companion.CompanionDeviceManager#associate(AssociationRequest, android.companion.CompanionDeviceManager.Callback, Handler)) and have the android.Manifest.permission#BLUETOOTH_CONNECT permission. Alternatively, if the caller has the android.Manifest.permission#BLUETOOTH_PRIVILEGED permission, they can bypass the Companion Device Manager association requirement as well as other permission requirements.

Java documentation for android.bluetooth.BluetoothDevice.setAlias(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to