Android NsdManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android NsdManager class.

This code example shows how to use the following methods: setEnabled
 
    public boolean onPreferenceChange(Preference preference, Object value) {
 
        final boolean desiredState = (Boolean) value;
        mCheckbox.setEnabled(false);
        mNsdManager.setEnabled(desiredState);
        return false; 
    } 
 
    private void handleNsdStateChanged(int newState) {
        switch (newState) {
            case NsdManager.NSD_STATE_DISABLED:
                mCheckbox.setChecked(false);
                mCheckbox.setEnabled(true);
                break; 
            case NsdManager.NSD_STATE_ENABLED:
                mCheckbox.setChecked(true);
                mCheckbox.setEnabled(true);
                break; 
        } 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: stopServiceDiscovery
        mNsdManager.discoverServices(
                SERVICE_TYPE, NsdManager.PROTOCOL_DNS_SD, mDiscoveryListener);
    } 
     
    public void stopDiscovery() { 
        mNsdManager.stopServiceDiscovery(mDiscoveryListener);
    } 
 
    public NsdServiceInfo getChosenServiceInfo() {
        return mService;
    } 
     
    public void tearDown() { 
        mNsdManager.unregisterService(mRegistrationListener);
    } 
} 
Full Snippet Info
5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: registerService
     * Register service to mDNS/DNS-SD. 
     */ 
    void registerService() { 
        NsdServiceInfo serviceInfo = allocateServiceInfo();
        int protocolType = NsdManager.PROTOCOL_DNS_SD;
        nsdManager.registerService(serviceInfo, protocolType, registrationListener);
    } 
 
    /** 
     * Unregister service from mDNS/DNS-SD. 
     */ 
    void unregisterService() { 
        if (regstrationListenerRegistered)
            nsdManager.unregisterService(registrationListener);
    } 
 
    // Activity's lifecycle methods. 
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: stopServiceDiscovery
			@Override 
			public void onStartDiscoveryFailed(String serviceType, int errorCode) {
				Log.d(TAG,
						"DiscoveryListener#onStartDiscoveryFailed errorCode=" 
								+ errorCode);
				mNsdManager.stopServiceDiscovery(this);
			} 
 
			@Override 
			public void onServiceFound(final NsdServiceInfo service) {
				Log.d(TAG, "DiscoveryListener#onServiceFound service="
						+ service);
				if (!service.getServiceType().equals(sServiceType)) {
					Log.d(TAG,
							"Unknown Service Type: " + service.getServiceType());
				} else if (service.getServiceName().startsWith(mServiceName)) {
					// 少し乱暴だけど、同一マシンが "わかめ (2)" とかいって複数検出されるので。 
					Log.d(TAG, "Same machine: " + mServiceName);
				} else { 
					Log.d(TAG, "New service found: " + mServiceList.size());
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: stopServiceDiscovery
		} 
 
		@Override 
		public void onStartDiscoveryFailed(String serviceType, int errorCode) {
			Log.e(TAG, "Discovery failed: Error code:" + errorCode);
			_NsdManager.stopServiceDiscovery(this);
			 
		} 
 
		@Override 
		public void onStopDiscoveryFailed(String serviceType, int errorCode) {
			Log.e(TAG, "Discovery failed: Error code:" + errorCode);
			_NsdManager.stopServiceDiscovery(this);
			 
		} 
		 
	} 
 
	 
 
Full Snippet Info
4
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Android NsdManager Methods: