Example usage for android.net.nsd NsdServiceInfo setServiceName

List of usage examples for android.net.nsd NsdServiceInfo setServiceName

Introduction

In this page you can find the example usage for android.net.nsd NsdServiceInfo setServiceName.

Prototype

public void setServiceName(String s) 

Source Link

Document

Set the service name

Usage

From source file:org.drulabs.localdash.nsddiscovery.NsdHelper.java

public void registerService(int port) {
    tearDown(); // Cancel any previous registration request
    initializeRegistrationListener();//from  w w  w  .j  a va  2 s . c o  m
    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setPort(port);
    serviceInfo.setServiceName(mServiceName);
    serviceInfo.setServiceType(SERVICE_TYPE);
    Log.v(TAG, Build.MANUFACTURER + " registering service: " + port);
    mNsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
}

From source file:ibp.plugin.nsd.NSDHelper.java

public void registerService(String name, int port) {
    NsdServiceInfo serviceInfo = new NsdServiceInfo();
    serviceInfo.setPort(port);/*ww w  .j  a va2 s . c o  m*/
    serviceInfo.setServiceName(name);
    serviceInfo.setServiceType(SERVICE_TYPE);
    mNsdManager.registerService(serviceInfo, NsdManager.PROTOCOL_DNS_SD, mRegistrationListener);
}

From source file:ibp.plugin.nsd.NSDHelper.java

public void initializeResolveListener() {
    mResolveListener = new NsdManager.ResolveListener() {
        @Override//ww  w . java2s  .com
        public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
            resolveServiceCB.error("onResolveFailed: " + errorCode);
        }

        @Override
        public void onServiceResolved(NsdServiceInfo serviceInfo) {
            String oldName = serviceInfo.getServiceName();
            String newName = oldName.replace("\\032", " ");
            serviceInfo.setServiceName(newName);
            reWriteServiceInfo(serviceInfo);
            resolveServiceCB.success(NsdServiceInfoToJSON(serviceInfo));
        }
    };
}