Code example for NsdManager

Methods: discoverServices

0
 
		mServiceName = mCallback.getServiceName();
		mConnection = new P2pServer(this); // 内部で registerService を呼び出す
 
		mDiscoveryListener = generateDiscoveryListener();
		mNsdManager.discoverServices(sServiceType, NsdManager.PROTOCOL_DNS_SD,
				mDiscoveryListener);
	} 
 
	@Override 
	public void onDetach() { 
		if (mRegistrationListener != null) {
			mNsdManager.unregisterService(mRegistrationListener);
			mConnection.tearDown();
			mConnection = null;
		} 
		mNsdManager.stopServiceDiscovery(mDiscoveryListener);
 
		super.onDetach(); 
	}