BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
或者
BluetoothAdapter adapter = (BluetoothAdapter) getApplicationContext().getSystemService(BLUETOOTH_SERVICE);
String macAddr = adapter.getAddress();
Object bluetoothManageService = new Mirror().on(adapter).get().field("mService");
if (bluetoothManageService == null)
return null;
Object address = new Mirror().on(bluetoothManageService).invoke().method("getAddress").withoutArgs();
if (address != null && address instanceof String) {
return (String) address;
} else {
return null;
}
implementation 'net.vidageek:mirror:1.6.1'