Back to project page Android-Apps.
The source code is released under:
Apache License
If you think the Android project Android-Apps listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.kniezrec.xbmcgear.connection; // w ww . j a v a 2s .c o m import android.content.Context; import android.net.nsd.NsdManager; import android.net.nsd.NsdServiceInfo; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log; class NSDResolve implements Runnable { private static final String TAG = "NSDSearch"; private final Handler handler; private final NsdServiceInfo serviceIn; public NSDResolve(Handler handler, NsdServiceInfo serviceInfo) { this.handler = handler; this.serviceIn = serviceInfo; } @Override public void run() { NsdManager mNsdManager; NsdManager.ResolveListener mResolveListener; Context context = AndroidApplication.getInstance() .getApplicationContext(); mNsdManager = (NsdManager) context .getSystemService(Context.NSD_SERVICE); mResolveListener = new NsdManager.ResolveListener() { @Override public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) { Log.e(TAG, "Resolve failed" + errorCode); } @Override public void onServiceResolved(NsdServiceInfo serviceInfo) { Message msg = Message.obtain(); msg.what = NSDSearch.ADD_TO_RESOLVED; Bundle b = new Bundle(); b.putParcelable(NSDSearch.RESOLVED, serviceInfo); msg.setData(b); handler.sendMessage(msg); } }; mNsdManager.resolveService(this.serviceIn, mResolveListener); } }