Android NsdServiceInfo - 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 NsdServiceInfo class.

This code example shows how to use the following methods:setPort, setServiceName, setServiceType
This code example shows how to use the following methods:getHost, getPort
 
    public void clickConnect(View v) {
        NsdServiceInfo service = mNsdHelper.getChosenServiceInfo();
        if (service != null) {
            Log.d(TAG, "Connecting.");
            mConnection.connectToServer(service.getHost(),
                    service.getPort());
        } else { 
            Log.d(TAG, "No service to connect to!");
        } 
    } 
 
    public void clickSend(View v) {
        EditText messageView = (EditText) this.findViewById(R.id.chatInput);
        if (messageView != null) {
            String messageString = messageView.getText().toString();
            if (!messageString.isEmpty()) {
                mConnection.sendMessage(messageString);
            } 
            messageView.setText("");
6
CodeRank
This code example shows how to use the following methods:setPort, setServiceName, setServiceType
     * Allocate ServiceInfo object for register service. 
     *  
     * @return 
     */ 
    static NsdServiceInfo allocateServiceInfo() {
        NsdServiceInfo serviceInfo = new NsdServiceInfo();
        serviceInfo.setPort(SERVICE_PORT);
        serviceInfo.setServiceName(SERVICE_NAME);
        serviceInfo.setServiceType(SERVICE_TYPE);
        return serviceInfo;
    } 
 
    /** The instance of NsdManager */ 
    NsdManager nsdManager;
 
    /** 
     * Ensure SystemService objects. 
     */ 
    void ensureSystemServices() { 
        nsdManager = (NsdManager) getSystemService(NSD_SERVICE);
7
CodeRank
This code example shows how to use the following methods:getServiceName, getServiceType
 
			@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());
					addToList(service);
				} 
			} 
 
			@Override 
			public void onServiceLost(final NsdServiceInfo service) {
				removeFromList(service);
6
CodeRank
This code example shows how to use the following methods:setPort, setServiceName, setServiceType
	public static void unregisterService() { 
		mNsdManager.unregisterService(mRegistrationListener);
	} 
 
	private static void registerService(int port) {
		NsdServiceInfo serviceInfo = new NsdServiceInfo();
 
		serviceInfo.setServiceName(Build.SERIAL + "TEST-TEST"
				+ new Date().getTime());
		serviceInfo.setServiceType(SERVICE_TYPE);
		serviceInfo.setPort(port);
 
		mNsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD,
				mRegistrationListener);
	} 
 
	@Override 
	public IBinder onBind(Intent intent) {
		return null; 
	} 
6
CodeRank
This code example shows how to use the following methods:setPort, setServiceName, setServiceType
This code example shows how to use the following methods:getServiceName
	} 
 
	@Override 
	public void onServiceLost(NsdServiceInfo service) {
	    Log.d(TAG, "Service lost " + service);
	    solvedServiceName.remove(service.getServiceName());
	    serviceFound.remove(service);
	    fireServiceLost(service);
	} 
 
	@Override 
	public void onServiceFound(NsdServiceInfo service) {
	    Log.d(TAG, "service found " + service.getServiceName());
	    serviceFound.add(service);
	    fireServiceFound(service);
	} 
 
	@Override 
	public void onDiscoveryStopped(String arg0) {
	    Log.d(TAG, "Stop discovery for " + arg0);
5
CodeRank
This code example shows how to use the following methods:getServiceName, getServiceType
  /* (non-Javadoc) 
   * @see android.net.nsd.NsdManager.DiscoveryListener#onServiceFound(android.net.nsd.NsdServiceInfo) 
   */ 
  @Override 
  public void onServiceFound(NsdServiceInfo serviceInfo) {
    Log.d(TAG, "Found service:" + serviceInfo.getServiceType());
    if (serviceInfo.getServiceType() != CLEMENTINE_SERVICE_TYPE) {
      return; 
    } 
    Log.d(TAG, "Found clementine service: " + serviceInfo.getServiceName());
  } 
 
  /* (non-Javadoc) 
   * @see android.net.nsd.NsdManager.DiscoveryListener#onServiceLost(android.net.nsd.NsdServiceInfo) 
   */ 
  @Override 
  public void onServiceLost(NsdServiceInfo serviceInfo) {
  } 
 
  /* (non-Javadoc) 
5
CodeRank
This code example shows how to use the following methods:getServiceName, getServiceType
            } 
 
            @Override 
            public void onServiceFound(NsdServiceInfo serviceInfo) {
                logMsg("Service discovery found: " + serviceInfo);
                if (!serviceInfo.getServiceType().equals(SERVICE_TYPE)) {
                    logMsg("Unknown Service Type: " + serviceInfo.getServiceType());
                } else if (serviceInfo.getServiceName().equals(mServiceName)) {
                    logMsg("Same machine: " + mServiceName);
                } else if (serviceInfo.getServiceName().contains(mServiceName)) {
                    mNsdManager.resolveService(serviceInfo, mResolveListener);
                } 
            } 
 
            @Override 
            public void onServiceLost(NsdServiceInfo serviceInfo) {
                logMsg("service lost."); 
                if (serviceInfo == mService) {
                    mService = null;
                } 
4
CodeRank
This code example shows how to use the following methods:getServiceName, getServiceType
  /* (non-Javadoc) 
   * @see android.net.nsd.NsdManager.DiscoveryListener#onServiceFound(android.net.nsd.NsdServiceInfo) 
   */ 
  @Override 
  public void onServiceFound(NsdServiceInfo serviceInfo) {
    Log.d(TAG, "Found service:" + serviceInfo.getServiceType());
    if (serviceInfo.getServiceType() != CLEMENTINE_SERVICE_TYPE) {
      return; 
    } 
    Log.d(TAG, "Found clementine service: " + serviceInfo.getServiceName());
  } 
 
  /* (non-Javadoc) 
   * @see android.net.nsd.NsdManager.DiscoveryListener#onServiceLost(android.net.nsd.NsdServiceInfo) 
   */ 
  @Override 
  public void onServiceLost(NsdServiceInfo serviceInfo) {
  } 
 
  /* (non-Javadoc) 
5
CodeRank

Related Android NsdServiceInfo Questions & Answers:

See Code Examples for Android NsdServiceInfo Methods: