android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceInfo Java Examples
The following examples show how to use
android.net.wifi.p2p.nsd.WifiP2pDnsSdServiceInfo.
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: Salut.java From Salut with MIT License | 5 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void createService(final SalutCallback onSuccess, final SalutCallback onFailure) { manager.clearLocalServices(channel, null); Log.d(TAG, "Starting " + thisDevice.serviceName + " Transport Protocol " + TTP); //Inject the listening port along with whatever else data that is going to be sent. thisDevice.txtRecord.put("LISTEN_PORT", String.valueOf(thisDevice.servicePort)); //Create a service info object will android will actually hand out to the clients. serviceInfo = WifiP2pDnsSdServiceInfo.newInstance(thisDevice.instanceName, TTP, thisDevice.txtRecord); //Register our service. The callbacks here just let us know if the service was registered correctly, //not necessarily whether or not we connected to a device. manager.addLocalService(channel, serviceInfo, new WifiP2pManager.ActionListener() { @Override public void onSuccess() { Log.v(TAG, "Successfully added the local service."); if (onSuccess != null) onSuccess.call(); } @Override public void onFailure(int error) { Log.e(TAG, "Failed to create " + thisDevice.serviceName + " : Error Code: " + error); if (onFailure != null) onFailure.call(); isRunningAsHost = false; } }); }