Search code examples
wifiandroid-wifiwifi-directwifimanager

Wifi Direct Group Owner Address


That's an easy question, I've to get the "Group Owner address" using "Wifi direct", I know that this is in WifiP2pInfo.GroupOwnerAddress, but how can I initialize WifiP2pInfo.groupOnwerAddress to get the Group Owner address in my application?

Could someone give me a pass to pass? I'm new in android and java.

Many Thanks.


Solution

  • NetworkInfo networkInfo = (NetworkInfo)intent.getParcelableExtra(extraKey);
    
      if (networkInfo.isConnected()) {
        wifiP2pManager.requestConnectionInfo(wifiDirectChannel, 
          new ConnectionInfoListener() {
            public void onConnectionInfoAvailable(WifiP2pInfo info) { 
    
    
                Toast toast=Toast.makeText(class.this,info.groupOwnerAddress.getHostAddress().toString, Toast.LENGHT_SHORT); 
                toast.show();    
    
            }
          }
      }
    

    Sorry for late answer. This is owner IP info.groupOwnerAddress.getHostAddress().toString