Code example for NsdManager

Methods: resolveService

0
 
	@Override 
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		String serviceName = adapter.getItem(position);
		NsdServiceInfo serviceInfo = serviceMap.get(serviceName);
		nsdManager.resolveService(serviceInfo, this);
	} 
 
	@Override 
	public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
		Toast.makeText(this, "Resolve failed: " + errorCode, Toast.LENGTH_SHORT).show();
	} 
 
	@Override 
	public void onServiceResolved(NsdServiceInfo serviceInfo) {
		Intent intent = new Intent(this, SyncActivity.class);
		intent.putExtra(SyncActivity.EXTRA_SERVICE_INFO, serviceInfo);
		startActivity(intent);
		finish();
	}