android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceRequest源码实例Demo

类android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceRequest源码实例Demo

下面列出了android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceRequest 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: WiFi-Buddy   文件: WifiDirectHandler.java
private void addServiceDiscoveryRequest() {
    serviceRequest = WifiP2pDnsSdServiceRequest.newInstance();

    // Tell the framework we want to scan for services. Prerequisite for discovering services
    wifiP2pManager.addServiceRequest(channel, serviceRequest, new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {
            Log.i(TAG, "Service discovery request added");
        }

        @Override
        public void onFailure(int reason) {
            Log.e(TAG, "Failure adding service discovery request: " + FailureReason.fromInteger(reason).toString());
            serviceRequest = null;
        }
    });
}
 
源代码2 项目: gilgamesh   文件: WifiController.java
public void init (GilgaService service)
{
 mService = service;

     mWifiManager = (WifiP2pManager) mService.getSystemService(Context.WIFI_P2P_SERVICE);
     
     mWifiChannel = mWifiManager.initialize(mService, mService.getMainLooper(), new ChannelListener()
     {

@Override
public void onChannelDisconnected() {
	Log.d(GilgaService.TAG,"wifi p2p disconnected");
}
     	
     });
     
     WifiP2pDnsSdServiceRequest serviceRequest = WifiP2pDnsSdServiceRequest.newInstance();
     mWifiManager.addServiceRequest(mWifiChannel,
             serviceRequest,
             new ActionListener() {
                 @Override
                 public void onSuccess() {
                     // Success!
 	            	Log.d(TAG,"SUCCESS: added service request wifi name service");

                 }

                 @Override
                 public void onFailure(int code) {
                     // Command failed.  Check for P2P_UNSUPPORTED, ERROR, or BUSY
                 	Log.d(TAG,"FAILURED: added service request wifi name service: " + code);
                 }
             });
     
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法