更新我的播放服務,就近版本'10 .2.0' ,它改變從界面到抽象類的EndpointDiscoveryListener和ConnectionRequestListener,我EndpointDiscoveryListener延長NearbyClient並宣佈內部類ConnectionRequestListener,現在我看到AppIdentifier已過時過,我搜索了很多在谷歌,但我找不到任何新的例子, 這裏是我的代碼,我從GitHub playgameservices改變:如何在新的play-services-nearby中實現抽象類EndpointDiscoveryListener和ConnectionRequestListener?
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);
}
}
}
的代碼的其餘部分是相同的例子。 實施新版本的最佳方式是什麼?
它顯示我「不幸的是,Google Play服務已停止」,當我想作爲客戶端連接時, 什麼是棄用新版本?
你運行8bitartist?因爲它不適合我。如果你確實請給我發送新的?或更換在github –
樣本已更新:https://github.com/playgameservices/android-basic-samples有一個已知的bug但是,播放服務有時會打電話時stopDiscovery()或stopAdvertising()崩潰。他們正在修復它,並將在下一次SDK更新中。 –
請讓我知道,如果錯誤糾正 –