简体   繁体   English

Android中的Bluez实现

[英]Bluez implementation in android

Can anyone please provide us any source code for bluez implementation in android. 任何人都可以向我们提供在Android中实现bluez的任何源代码。 Actually we are trying to make an application with GATT profile. 实际上,我们正在尝试使用GATT配置文件创建应用程序。 This android application should connect with other device by Bluetooth connection. 此android应用程序应通过蓝牙连接与其他设备连接。 Please suggest me what should be the best way to send data to a non android device. 请建议我什么是将数据发送到非Android设备的最佳方法。

Look at Bluetooth chat example by Google, you also can use the same method to connect to a non android device. 查看Google的蓝牙聊天示例,您也可以使用相同的方法连接到非Android设备。 Specifically you will need this api 具体来说,您将需要此api

device.createRfcommSocketToServiceRecord(SerialPortServiceClass_UUID); device.createRfcommSocketToServiceRecord(SerialPortServiceClass_UUID);

EDIT: You can also try using reflection to access another method like this 编辑:您也可以尝试使用反射来访问这样的另一种方法

Method m = mmDevice.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
mmSocket = (BluetoothSocket) m.invoke(mmDevice, Integer.valueOf(1));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM