Wi-Fi Direct Discovery无法在Android Marshmallow 6.0

时间:2016-05-04 20:35:06

标签: java android android-6.0-marshmallow wifip2p

public void discoverpeers(View v) {
    wifiP2pManager.discoverPeers(channel, new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {
            Toast.makeText(getApplicationContext(), "Peer Discovery Successful", Toast.LENGTH_LONG).show();
        }

        @Override
        public void onFailure(int reason) {
            Toast.makeText(WiDiActivity.this, reason + "", Toast.LENGTH_SHORT).show();
            Toast.makeText(getApplicationContext(), "Peer Discovery Failed", Toast.LENGTH_LONG).show();
        }
    });
}

对等点发现失败,原因= 0.我使用的Android版本是6.0。该代码在版本低于6.0的其他设备上运行完美 我也打开了我的位置设置。 我使用了以下许可:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

1 个答案:

答案 0 :(得分:0)

尝试查看您是否可以运行Android的Wi-Fi Direct demo