3

Android Network Service Discovery provides us with an onResolveFailed() callback, like so:

NsdManager.ResolveListener mResolveListener = new NsdManager.ResolveListener() {

    @Override
    public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
        // Called when the resolve fails. Use the error code to debug.
        Log.e(TAG, "Resolve failed " + errorCode);
    }
};

In my case, I get errorCode 3.

What do these erorCodes stand for and where would I find that specified?

Ivo Renkema
  • 2,188
  • 1
  • 29
  • 40

2 Answers2

10

It's right there in the documentation you link to

enter image description here

Tim
  • 41,901
  • 18
  • 127
  • 145
0

use thread sleep then we cant get this type of error

            @Override
    public void onServiceFound(final NsdServiceInfo service) {

       if(service.getServiceName()!=null) {


              try {

            Log.d(TAG, "Service discovery success = " + service.toString());

            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }


                  mNsdManager.resolveService(service,new NsdManager.ResolveListener() {

                      @Override
                      public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) {
                          // Called when the resolve fails.  Use the error code to debug.
                          Log.e(TAG, "Resolve failed" + errorCode);


                      }

                      @Override
                      public void onServiceResolved(NsdServiceInfo serviceInfo) {

                          Log.e(TAG, "Resolve Succeeded. " + serviceInfo);


                          String mHostFound = serviceInfo.getHost().getHostAddress();
                          int mPortFound = serviceInfo.getPort();


                          System.out.println(serviceInfo.getServiceName());
                          System.out.println(mHostFound);
                          System.out.println(mPortFound);

                      }
                  });


              } catch (Exception e) {
                  e.printStackTrace();
              }

            }


    }                

this woks for me thank you