Skip to content Skip to sidebar Skip to footer

Android Wifi Direct Device Details

I'd like to know how I can change the device details of WiFi Direct interface of an Android device (for example the name of interface). I'm developing an application that uses Blue

Solution 1:

The Wi-Fi direct Name is the device name, you can change it by the following way:

public void changeWiFiDirectName(final String newName){
Method m = null;
try {
    m = mManager.getClass().getMethod("setDeviceName", new Class[]{mChannel.getClass(), String.class, WifiP2pManager.ActionListener.class});
} catch (NoSuchMethodException e) {
    e.printStackTrace();
}
try {
    if (m != null) {
        m.invoke(mManager, mChannel,newName, new WifiP2pManager.ActionListener() {

            @Override
            public void onSuccess() {
                Log.d(TAG, "Name changed to "+newName);
            }
            @Override
            public void onFailure(int reason) {
                Log.d(TAG, "The name was not changed");
            }
        });
    }
} catch (IllegalAccessException e) {
    e.printStackTrace();
} catch (InvocationTargetException e) {
    e.printStackTrace();
}

Post a Comment for "Android Wifi Direct Device Details"