public static String getBluetoothAddress() {
String bluetoothAddress = "";
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
System.out.println(">>>>>>>>>> android_sdk_version=" + Build.VERSION.SDK_INT);
if(Build.VERSION.SDK_INT < 23){
bluetoothAddress = bluetoothAdapter.getAddress();
}else {
Object bluetoothManagerService = new Mirror().on(bluetoothAdapter).get().field("mService");
if (bluetoothManagerService != null) {
Object address = new Mirror().on(bluetoothManagerService).invoke().method("getAddress").withoutArgs();
if (address != null && address instanceof String) {
bluetoothAddress = (String) address;
}
}
}
return bluetoothAddress;
}