user3235290
user3235290

Reputation: 93

Android: Nearby api, No Connection

I am attempting to get Google Nearby API working on my handset (an s5).

I am building and running the stock project from github Google Nearby API GIT.

The app builds and runs, with no errors. Having exported the app onto two S5s (amongst other handsets I have attempted to test it with) and connecting to a WLAN from a D-Link DSL-3680. Multicasting is enabled and set to v3.

However the app refuses to connect with the neighbouring phone when corresponding 'advertise' and 'discover' instructions have been given.

Is there an effective way in which to debug this behaviour? If I can provide an effective information dump of information that might help someone identify the issue then please let me know how.

Upvotes: 1

Views: 782

Answers (1)

Neeraj Thakur
Neeraj Thakur

Reputation: 56

What do you mean by 'refuse to connect'? are you getting connection status- 'Rejected'?

If you are able to advertise and discover other devices, I'm assuming all your base conditions (like connected to local network) are fulfilled

Now,

You can try logging your status in Connection call back when you try to connect

Nearby.Connections.sendConnectionRequest(mGoogleApiClient, myName,
remoteEndpointId, myPayload, new Connections.ConnectionResponseCallback() {//response conditions}

using-- inside connection callback function write

          if(status.isSuccess()){
           // Successful connection
        } else {
          // Failed connection
        }

similarly, if you are not doing this, you need to accept the connection request

Nearby.Connections.acceptConnectionRequest(mGoogleApiClient, remoteEndpointId, myPayload, this)

and inside Onresult callback add-

      if(status.isSuccess()){
       // Successful connection
    } else {
      // Failed connection
    }

Hope it helped

Upvotes: 1

Related Questions