Android Bluetooth蓝牙技术初体验

2019-12-10 19:08:18王冬梅

3、通过BluetoothDevice.createRfcommSocketToServiceRecord (UUID uuid)方法创建BluetoothSocket对象。 
4、通过BluetoothSocket.connect()方法来连接蓝牙设备。 
5、通过BluetoothSocket.getInputStream()和BluetoothSocket.getOutputStream()方法获得读写数据的InputStream和OutputStream对象。 
6、通过InputStream.read()方法来读数据。通过OutputStream.write()方法来写数据。

四:Tip

UUID

// UUID:全局唯一标识符,格式为:8-4-4-4-12
// 两个蓝牙设备进行连接需要使用同一个UUID

<uses-permissionandroid:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permissionandroid:name="android.permission.BLUETOOTH" />

以上所述是小编给大家分享的Android Bluetooth蓝牙技术初体验的相关内容,下篇将给大家介绍Android Bluetooth蓝牙技术使用流程详解,感兴趣的朋友可以点击了解详情。



注:相关教程知识阅读请移步到Android开发频道。