I update my play-services-nearby to version '10.2.0', it changes the EndpointDiscoveryListener and ConnectionRequestListener from interface to abstract class, I extend NearbyClient with EndpointDiscoveryListener and declare inner class ConnectionRequestListener , now I see that AppIdentifier is deprecated too, I searched a lot in google but I can't find any new example, here is my code I changed from github playgameservices :
public class NearbyClient extends Connections.EndpointDiscoveryListener implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
Connections.MessageListener {
private class OnConnectionRequest extends Connections.ConnectionRequestListener {
private NearbyClient mNearbyClient;
OnConnectionRequest(NearbyClient nearbyClient)
{
this.mNearbyClient = nearbyClient;
}
@Override
public void onConnectionRequest(final String remoteEndpointId, final String remoteEndpointName, byte[] payload) {
Log.d(TAG, "onConnectionRequest:" + remoteEndpointId +
":" + remoteEndpointName);
if (mIsHost) {
// The host accepts all connection requests it gets.
byte[] myPayload = null;
Nearby.Connections.acceptConnectionRequest(mGoogleApiClient, remoteEndpointId,
myPayload, mNearbyClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
Log.d(TAG, "acceptConnectionRequest:" + status + ":" + remoteEndpointId);
if (status.isSuccess()) {
Toast.makeText(mContext, "Connected to " + remoteEndpointName,
Toast.LENGTH_SHORT).show();
// Record connection
HeroParticipant participant = new HeroParticipant(remoteEndpointId, remoteEndpointName);
mConnectedClients.put(remoteEndpointId, participant);
// Notify listener
mListener.onConnectedToEndpoint(remoteEndpointId, remoteEndpointName);
} else {
Toast.makeText(mContext, "Failed to connect to: " + remoteEndpointName,
Toast.LENGTH_SHORT).show();
}
}
});
} else {
// Clients should not be advertising and will reject all connection requests.
Log.w(TAG, "Connection Request to Non-Host Device - Rejecting");
Nearby.Connections.rejectConnectionRequest(mGoogleApiClient, remoteEndpointId);
}
}
}
the rest of the code is same as example.
What is the best way to implement new version?
it shows me "Unfortunately, Google Play Services has stopped" when I want to connect as a client,
What is the deprecation new version?