I am trying to connect two devices using Wifi Direct, but i want to implement programmatically not by user initiated.
And for that i have to change Device's WifiDirect's name like below picture :
Now discover peers using following methods :
wifiP2pManager.discoverPeers(channel,
new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
Log.d(TAG, "onSuccess");
}
@Override
public void onFailure(int reason) {
Log.d(TAG, "onFailure");
}
});
Connect to particular peer via following code :
public static void connectPeer(WifiP2pDevice device,
WifiP2pManager manager, Channel channel, final Handler handler) {
WifiP2pConfig config = new WifiP2pConfig();
config.groupOwnerIntent = 15;
config.deviceAddress = device.deviceAddress;
config.wps.setup = WpsInfo.PBC;
manager.connect(channel, config, new ActionListener() {
@Override
public void onSuccess() {
}
@Override
public void onFailure(int reason) {
}
});
}
But i dont know how to change device name for Wi-Fi Direct?
this is what worked for me, even though I don't recommend using reflection to access hidden APIs in the WifiP2pManager.