android bluetooth已知了bluetoothDevice的mac地址 怎么得到bluetoothDevice
androidbluetooth得到了bluetoothDevicemac地址(不是搜索配对得到的)接下来怎么生成bluetoothSocket(msocket=blue...
android bluetooth得到了bluetoothDevicemac地址(不是搜索配对得到的) 接下来怎么生成bluetoothSocket (msocket=bluetoothDevice.creatRfcommSocketToServiceRecord(UUID 知道了bluetoothDevice的mac 怎么得到这个bluetoothDevice?)
展开
展开全部
使用BluetoothAdapter类提供的方法getRemoteDevice 创建BluetoothDevice实例。
提醒一句,BluetoothAdapter实例应使用 BluetoothAdapter.getDefaultAdapter ()静态方法获取。
以下摘译自android文档。
public BluetoothDevice getRemoteDevice (String address)
Since: API Level 5
Get a BluetoothDevice object for the given Bluetooth hardware address.
Valid Bluetooth hardware addresses must be upper case, in a format such as "00:11:22:33:AA:BB". The helper checkBluetoothAddress(String) is available to validate a Bluetooth address.
通过指定的硬件地址获取BluetoothDevice对象。有效的蓝牙硬件地址必须是形如"00:11:22:33:AA:BB"的大写字符串。可使用辅助方法checkBluetoothAddress(String)校验地址(格式)的有效性。
A BluetoothDevice will always be returned for a valid hardware address, even if this adapter has never seen that device.
如地址有效则一个对应的BluetoothDevice对象被返回,即使适配器并未发现该设备。
Parameters 参数
address valid Bluetooth MAC address 有效的蓝牙MAC地址
Throws
IllegalArgumentException if address is invalid
提醒一句,BluetoothAdapter实例应使用 BluetoothAdapter.getDefaultAdapter ()静态方法获取。
以下摘译自android文档。
public BluetoothDevice getRemoteDevice (String address)
Since: API Level 5
Get a BluetoothDevice object for the given Bluetooth hardware address.
Valid Bluetooth hardware addresses must be upper case, in a format such as "00:11:22:33:AA:BB". The helper checkBluetoothAddress(String) is available to validate a Bluetooth address.
通过指定的硬件地址获取BluetoothDevice对象。有效的蓝牙硬件地址必须是形如"00:11:22:33:AA:BB"的大写字符串。可使用辅助方法checkBluetoothAddress(String)校验地址(格式)的有效性。
A BluetoothDevice will always be returned for a valid hardware address, even if this adapter has never seen that device.
如地址有效则一个对应的BluetoothDevice对象被返回,即使适配器并未发现该设备。
Parameters 参数
address valid Bluetooth MAC address 有效的蓝牙MAC地址
Throws
IllegalArgumentException if address is invalid
参考资料: http://developer.android.com/reference/android/bluetooth/BluetoothAdapter.html
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询