当前位置: 首页>>代码示例>>Java>>正文


Java Player.getPlayerId方法代码示例

本文整理汇总了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 
}
 
开发者ID:Magicrafter13,项目名称:1946,代码行数:28,代码来源:GooglePlayServicesExtension.java

示例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);			
  }
 
开发者ID:cranberrygame,项目名称:cordova-plugin-game,代码行数:32,代码来源:Game.java


注:本文中的com.google.android.gms.games.Player.getPlayerId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。