I know this is late.
But you can try this. Here you have to pass WifiP2pManager instance
alogn with WifiP2pManager.Channel instance
and your custom name
that you want to set.
This worked for me, Hope it will help you too.
/*
Set WifiP2p Device Name
*/
public void setDeviceName(WifiP2pManager manager, WifiP2pManager.Channel channel, String deviceName){
//set device name programatically
try {
Class[] paramTypes = new Class[3];
paramTypes[0] = WifiP2pManager.Channel.class;
paramTypes[1] = String.class;
paramTypes[2] = WifiP2pManager.ActionListener.class;
Method setDeviceName = manager.getClass().getMethod(
"setDeviceName", paramTypes);
setDeviceName.setAccessible(true);
Object arglist[] = new Object[3];
arglist[0] = channel;
arglist[1] = deviceName;
arglist[2] = new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
}
@Override
public void onFailure(int reason) {
}
};
setDeviceName.invoke(manager, arglist);
}
catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}