当我试图通过这种方式来获得的Android O设备上Blutooth地址:Secure.getString(mContext.getContentResolver(), “bluetooth_address”)返回的Android o原
private String getBlutoothAddress(Context mContext){
// Check version API Android
BluetoothAdapter myBluetoothAdapter;
String macAddress;
int currentApiVersion = android.os.Build.VERSION.SDK_INT;
if (currentApiVersion >= android.os.Build.VERSION_CODES.M) {
macAddress = Settings.Secure.getString(mContext.getContentResolver(), "bluetooth_address");
} else {
// Do this for phones running an SDK before lollipop
macAddress = myBluetoothAdapter.getAddress();
}
}
所有代码以上工作我仍然使用Anroid O(8.0)的代码,它返回macAddress = null。
我按照你的方式提问之前,但代码不工作,因为“LOCAL_MAC_ADDRESS权限是一个系统权限,所以在实践中你的应用程序不能拥有它。”就像你说的 。那么,没有任何解决方案可以在Android O上获得蓝牙地址? –
您想通过获取地址解决什么问题? – laalto
我使用蓝牙地址在我的应用程序中识别我的设备。你有任何想法来解决这个问题? –