xamarin.android蓝牙,在Android上连接Xamarin的配对蓝牙设备
請記住,Xamarin綁定到本機api所以不要擔心某些“與本機方式有關”;)基于你引用的anwser我編寫并測試了下面的代碼 . 我希望它會對你有所幫助 .
class btListener : Java.Lang.Object, IBluetoothProfileServiceListener
{
public void OnServiceConnected([GeneratedEnum] ProfileType profile, IBluetoothProfile proxy)
{
String deviceName = "JABRA WAVE+";
BluetoothDevice result = null;
var devices = BluetoothAdapter.DefaultAdapter.BondedDevices;
if (devices != null)
{
foreach (BluetoothDevice device in devices)
{
if (deviceName == device.Name)
{
result = device;
break;
}
}
}
var connect = Java.Lang.Class.FromType(typeof(BluetoothA2dp)).GetDeclaredMethod("connect", Java.Lang.Class.FromType(typeof(BluetoothDevice)));
connect.Invoke((Java.Lang.Object)proxy, result);
}
public void OnServiceDisconnected([GeneratedEnum] ProfileType profile)
{
}
}
以下代碼如下OnCreate功能:
btListener btReceiver = new btListener();
BluetoothAdapter.DefaultAdapter.GetProfileProxy(this, btReceiver, ProfileType.A2dp);
只是看了一下日期..但我還是張貼了答案 - 也許它仍然會幫助某人
總結
以上是生活随笔為你收集整理的xamarin.android蓝牙,在Android上连接Xamarin的配对蓝牙设备的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android camera 检测,检测
- 下一篇: html5电影在线看,HTML5-电影影