Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the errorCodes mean for Android NSD onResolveFailed()

Tags:

android

nsd

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?

like image 845
Ivo Renkema Avatar asked Sep 05 '26 14:09

Ivo Renkema


2 Answers

It's right there in the documentation you link to

enter image description here

like image 135
Tim Avatar answered Sep 08 '26 04:09

Tim


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

like image 43
sriram varma Avatar answered Sep 08 '26 03:09

sriram varma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!