高通平台WIFII-获取P2P0的Mac地址是02:00:00:00:00:00的解决思路

由于Google在Android 6之后做了保护,导致第三方app获取的Mac地址都是02:00:00:00:00:00

解决方法:

在代码中进行requestDeviceInfo申请一次

@RequiresApi(api = Build.VERSION_CODES.Q)
private String p2p0MacAddress = "";
private WifiP2pManager mWifiP2pManager;
private void UpdateP2P0MacAddress() {
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    mWifiP2pManager = (WifiP2pManage

你可能感兴趣的:(WIFI,p2p)