Tôi đang gửi hình ảnh qua bluetooth trong android và muốn tìm nạp địa chỉ MAC của Thiết bị mà hình ảnh đang được gửi.cách lấy địa chỉ MAC của thiết bị kết nối bluetooth trong android
Vui lòng tìm bên dưới mã của tôi.
private void bluetoothadd(){
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
Log.e("Bluetooth ","not found");
}
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivity(enableBtIntent);
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
// If there are paired devices
if (pairedDevices.size() > 0) {
// Loop through paired devices
for (BluetoothDevice device : pairedDevices) {
Log.e("Mac Addressess","are: "+mBluetoothAdapter.getRemoteDevice(device.getAddress()));
}
}
}
}
Tôi nhận được tất cả địa chỉ MAC của thiết bị được ghép nối. Tôi chỉ muốn địa chỉ MAC của một thiết bị mà dữ liệu được truyền đi.
Bạn muốn tìm địa chỉ, khi thiết bị khác được kết nối với thiết bị của người dùng, hoặc thậm chí trước khi kết nối được thiết lập (Discovery Phase) .. ??? – Shiva
Tôi muốn địa chỉ của một thiết bị khác khi nó được kết nối và tôi có thể nhận được địa chỉ MAC mà thiết bị đó đang gửi dữ liệu. –
kiểm tra theo các liên kết http://stackoverflow.com/questions/10795424/how-to-get-the-bluetooth-devices-as-a-list http://stackoverflow.com/questions/16471204/discovering-bluetooth-devices-listview-sẽ-không-được-cập nhật –