本文整理汇总了Java中com.google.android.gms.games.Player.getPlayerId方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getPlayerId方法的具体用法?Java Player.getPlayerId怎么用?Java Player.getPlayerId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.games.Player
的用法示例。
在下文中一共展示了Player.getPlayerId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConnected
import com.google.android.gms.games.Player; //导入方法依赖的package包/类
@Override
public void onConnected(Bundle connectionHint)
{
// The player is signed in. Hide the sign-in button and allow the
// player to proceed.
Log.i("yoyo","Sign In Succeeded");
Player p = Games.Players.getCurrentPlayer(getApiClient());
String displayName;
String id;
if (p == null) {
Log.i("yoyo", "mGamesClient.getCurrentPlayer() is NULL!");
displayName = "???";
id="-1";
}
else {
displayName = p.getDisplayName();
id = p.getPlayerId();
}
Log.i("yoyo","Found displayname " + displayName + " with id " + id);
RunnerJNILib.OnLoginSuccess(displayName,id,"","","","","");
//Call back to generate the social event
}
示例2: onSignInSucceeded
import com.google.android.gms.games.Player; //导入方法依赖的package包/类
@Override
public void onSignInSucceeded() {
//Util.alert(cordova.getActivity(), "onSignInSucceeded");
//https://github.com/freshplanet/ANE-Google-Play-Game-Services/blob/master/android/src/com/freshplanet/googleplaygames/functions/AirGooglePlayGamesGetActivePlayerName.java
//https://developer.android.com/reference/com/google/android/gms/games/Games.html#Players
//https://developer.android.com/reference/com/google/android/gms/games/Players.html#getCurrentPlayer(com.google.android.gms.common.api.GoogleApiClient)
//https://developer.android.com/reference/com/google/android/gms/games/Player.html
Player player = Games.Players.getCurrentPlayer(getGameHelper().getApiClient());
JSONObject playerDetail = new JSONObject();
try {
if (player != null)
{
String playerId = player.getPlayerId();
String displayName = player.getDisplayName();
//String title = player.getTitle();
playerDetail.put("playerId", playerId);
playerDetail.put("playerDisplayName", displayName);
}
}
catch(JSONException ex){
}
PluginResult pr = new PluginResult(PluginResult.Status.OK, playerDetail);
//pr.setKeepCallback(true);
loginCC.sendPluginResult(pr);
//PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
//pr.setKeepCallback(true);
//loginCC.sendPluginResult(pr);
}