Java Code Examples for android.net.nsd.NsdManager#discoverServices()

The following examples show how to use android.net.nsd.NsdManager#discoverServices() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NsdHelper.java    From snapdroid with GNU General Public License v3.0 5 votes vote down vote up
public void startListening(String serviceType, String serviceName, NsdHelperListener listener) {
        stopListening();
        this.listener = listener;
        this.serviceName = serviceName;
        this.serviceType = serviceType;
        initializeResolveListener();
        initializeDiscoveryListener();
        mNsdManager = (NsdManager) mContext.getSystemService(Context.NSD_SERVICE);
        mNsdManager.discoverServices(serviceType, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);
//        mNsdManager.discoverServices("_snapcast-jsonrpc._tcp.", NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);
    }
 
Example 2
Source File: ShareActivity.java    From nitroshare-android with MIT License 5 votes vote down vote up
void start() {
    mNsdManager = (NsdManager) getSystemService(Context.NSD_SERVICE);
    mNsdManager.discoverServices(Device.SERVICE_TYPE,
            NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);

    mThisDeviceName = new Settings(getContext()).getString(Settings.Key.DEVICE_NAME);
}
 
Example 3
Source File: MirrorService.java    From mirror with GNU General Public License v3.0 5 votes vote down vote up
private void onWifiConnected() {
    if (mIsWifiConnected) {
        return;
    }
    mIsWifiConnected = true;
    mIsWifiDisconnected = false;

    closeDiscoveryListenerSafety();
    RxBus.getInstance().post(new WifiConnectedEvent());

    mNsdManager = (NsdManager) getSystemService(NSD_SERVICE);
    mDiscoveryListener = buildDiscoveryListener();
    mNsdManager.discoverServices(SERVICE_TYPE, PROTOCOL_TYPE, mDiscoveryListener);
}
 
Example 4
Source File: ThetaDeviceDetectionFromLAN.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
@Override
public synchronized void start(final Context context) {
    if (mIsStarted) {
        return;
    }
    mIsStarted = true;
    mNsdManager = (NsdManager) context.getApplicationContext().getSystemService(Context.NSD_SERVICE);
    if (mNsdManager != null) {
        mNsdManager.discoverServices(SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, mNsdDiscoveryListener);
    }
}