【问题标题】:Wifi Direct Group Owner AddressWifi Direct 组所有者地址
【发布时间】:2013-03-25 17:38:43
【问题描述】:

这是一个简单的问题,我必须使用“Wifi direct”获取“组所有者地址”,我知道这是在 WifiP2pInfo.GroupOwnerAddress 中,但是我如何初始化 WifiP2pInfo.groupOnwerAddress 以获取组所有者地址我的申请?

谁能给我通行证? 我是android和java的新手。

非常感谢。

【问题讨论】:

    标签: wifi android-wifi wifi-direct wifimanager


    【解决方案1】:
    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();    
    
            }
          }
      }
    

    抱歉回复晚了。 这是所有者 IP info.groupOwnerAddress.getHostAddress().toString

    【讨论】:

      【解决方案2】:

      wifi 直连中的组所有者 IP 地址始终不变,即 192.168.49.1。要检查这一点,您可以在 BroadcastReceiver 类中进行以下更改。

         public void onReceive(Context context, Intent intent) {
                      String action = intent.getAction();
      
              if (WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION.equals(action)) {
      
                          if (mManager == null) {
                              return;
                          }
                          NetworkInfo networkInfo = (NetworkInfo) intent
                                  .getParcelableExtra(WifiP2pManager.EXTRA_NETWORK_INFO);
      
      
                          if (networkInfo.isConnected()) {
      
                              mManager.requestConnectionInfo(mChannel, new ConnectionInfoListener() {
      
                                  @Override
                                  public void onConnectionInfoAvailable(WifiP2pInfo info) {
      
                                      InetAddress groupOwnerAddress = info.groupOwnerAddress;
      
      
                                      String s=groupOwnerAddress.getHostAddress();
                                      Toast.makeText(mActivity, "Server IP Address "+s, Toast.LENGTH_SHORT).show();                
      
                                  }
                              });
                          }
                      }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-14
        相关资源
        最近更新 更多