I am trying to BroadCast Long string using wifi direct. when peer clicks on the device I want to manipulate this string. So I decided to attach this string with device name but device name change code is not working.
I tried to use the reflection of WifiManger API. But this method is hidden cannot be accessed.
try {
Method m = mManager.getClass().getMethod("setDeviceName", new Class[]{Channel.class, String.class, WifiP2pManager.ActionListener.class});
m.invoke(mManager, mChannel, BroadCastName, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
Log.d(TAG, "Name change successful.");
Log.println(Log.DEBUG,TAG, "Name change successful.");
}
@Override
public void onFailure(int reason) {
Log.d(TAG, "name change failed: " + reason);
}
});
} catch (Exception e) {
Log.d(TAG, "No such method");
}
this try catch block trying to access this method and use it to set custom string BroadCastName as Device Name or Host name
I want Device's Default Name in WifiDirect to be Modified as String BroadCastName but I see no change.