A lot of search on the net, can under 8.0, but in not more than 8.0, is there anyone who knows!
CodePudding user response:
Reflection
Private String getBluetoothMacAddress () {
BluetoothAdapter BluetoothAdapter=BluetoothAdapter. GetDefaultAdapter ();
String bluetoothMacAddress="";
If (android. OS. Build. VERSION. SDK_INT & gt;=android. OS. Build. VERSION_CODES. M) {
Try {
The Field mServiceField=bluetoothAdapter. GetClass (). GetDeclaredField (" mService ");
MServiceField. SetAccessible (true);
The Object btManagerService=mServiceField. Get (bluetoothAdapter);
If (btManagerService!=null) {
BluetoothMacAddress=(String) btManagerService. GetClass () getMethod (" getAddress "). The invoke (btManagerService);
}
} the catch (NoSuchFieldException e) {
} the catch (NoSuchMethodException e) {
} the catch (IllegalAccessException e) {
} the catch (InvocationTargetException e) {
}
} else {
BluetoothMacAddress=bluetoothAdapter. GetAddress ();
}
Return bluetoothMacAddress;
}
CodePudding user response:
Upstairs, 6.0 can be, but get less than 8.0, throw an exception
CodePudding user response:
Seems to make uncertain, I'm up for a long time
CodePudding user response:
What process?
If it is not reflection system apis abnormalities, see the GitHubhttps://github.com/tiann/FreeReflection
CodePudding user response: