Example usage for android.net.wifi.p2p.nsd WifiP2pDnsSdServiceInfo newInstance

List of usage examples for android.net.wifi.p2p.nsd WifiP2pDnsSdServiceInfo newInstance

Introduction

In this page you can find the example usage for android.net.wifi.p2p.nsd WifiP2pDnsSdServiceInfo newInstance.

Prototype

public static WifiP2pDnsSdServiceInfo newInstance(String instanceName, String serviceType,
        Map<String, String> txtMap) 

Source Link

Document

Create a Bonjour service information object.

Usage

From source file:test.microsoft.com.wifipairing.WifiAccessPoint.java

private void startLocalService(String instance) {

    Map<String, String> record = new HashMap<String, String>();
    record.put("available", "visible");

    WifiP2pDnsSdServiceInfo service = WifiP2pDnsSdServiceInfo.newInstance(instance, WifiBase.SERVICE_TYPE,
            record);// w  w  w  .j  av  a 2s.co m

    debug_print("Add local service :" + instance);
    p2p.addLocalService(channel, service, new WifiP2pManager.ActionListener() {
        public void onSuccess() {
            debug_print("Added local service");
        }

        public void onFailure(int reason) {
            debug_print("Adding local service failed, error code " + reason);
        }
    });
}

From source file:it.polimi.deib.p2pchat.discovery.chatmessages.waitingtosend.discovery.MainActivity.java

/**
 * Registers a local service.//ww  w .j a v  a  2s .  c om
 */
private void startRegistration() {
    Map<String, String> record = new HashMap<>();
    record.put(Configuration.TXTRECORD_PROP_AVAILABLE, "visible");

    WifiP2pDnsSdServiceInfo service = WifiP2pDnsSdServiceInfo.newInstance(Configuration.SERVICE_INSTANCE,
            Configuration.SERVICE_REG_TYPE, record);
    manager.addLocalService(channel, service,
            new CustomizableActionListener(MainActivity.this, "startRegistration", "Added Local Service", null,
                    "Failed to add a service", "Failed to add a service"));
}