我正在尝试使用A2DP配置文件控制与设备的蓝牙连接。在Android的本机Java开发中,开发人员利用BluetoothA2dp类进行连接。
Xamarin中有一个称为相同的类-BluetoothA2dp。但是我似乎无法理解如何初始化它的实例,因为它没有构造函数。
如何在该类端口的帮助下创建连接?
您不需要直接使用BluetoothA2dp类。根据Android文档...
BluetoothA2dp是用于通过IPC控制Bluetooth A2DP服务的代理对象。使用getProfileProxy(Context,BluetoothProfile.ServiceListener,int)获取BluetoothA2dp代理对象。
您应该BluetoothAdapter.GetProfileProxy
用来启动与A2DP代理对象的连接。
BluetoothAdapter.DefaultAdapter.GetProfileProxy(this, serviceListener, ProfileType.A2dp);
serviceListener
上面方法调用中的参数需要是实现的类的实例,IBluetoothProfileServiceListener
然后您可以在其中通过OnServiceConnected方法访问代理对象。
public void OnServiceConnected(ProfileType profile, IBluetoothProfile proxy)
{
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句