語言

BluetoothGattServer.AddService(BluetoothGattService) 方法

定義

將一項服務加入待主機服務清單。

[Android.Runtime.Register("addService", "(Landroid/bluetooth/BluetoothGattService;)Z", "")]
[Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")]
public bool AddService(Android.Bluetooth.BluetoothGattService? service);
[<Android.Runtime.Register("addService", "(Landroid/bluetooth/BluetoothGattService;)Z", "")>]
[<Android.Runtime.RequiresPermission("android.permission.BLUETOOTH_CONNECT")>]
member this.AddService : Android.Bluetooth.BluetoothGattService -> bool

參數

service
BluetoothGattService

服務將加入此裝置提供的服務清單中。

傳回

如果新增服務的請求已經啟動,則為真

屬性

備註

將一項服務加入待主機服務清單。

一旦服務加入清單,該服務及其包含的特性將由本地裝置提供。

如果本地裝置在呼叫此功能時已經暴露了服務,將會向所有用戶端發送服務更新通知。

BluetoothGattServerCallback#onServiceAdded回撥時會顯示該服務是否已成功新增。 在回電前請勿新增其他服務。

Java 文件 android.bluetooth.BluetoothGattServer.addService(android.bluetooth.BluetoothGattService)。

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於