根据Google Play游戏服务的质量检查清单,应用程序必须尝试“在游戏启动时自动提示玩家登录”并“记住如果玩家拒绝登录”,不要让应用程序每次启动时都向用户询问。那么,这个事件是什么呢?谷歌文档中没有任何参考资料。
请注意,在投票此问题是否重复之前,请注意我不是在询问如何知道用户是否已注销。我想做的是在第一次请求时获取用户的答案(如果被拒绝)并保留它。
请注意,在投票此问题是否重复之前,请注意我不是在询问如何知道用户是否已注销。我想做的是在第一次请求时获取用户的答案(如果被拒绝)并保留它。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
mResolvingConnectionFailure = false;
if (resultCode == RESULT_OK) {
googleApiClient.connect();
} else if (resultCode == RESULT_CANCELED) {
/*
* Put a boolean in your SharedPreferences
*/
} else {
BaseGameUtils.showActivityResultError(this, requestCode, resultCode, R.string.signin_other_error);
}
}
}
new AlertDialog.Builder(YourActivity.this)
.setTitle("Sign-in to Google")
.setMessage("Please sign-in to Google services")
.setPositiveButton(android.R.string.sign_in, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//Sign in the user
}
})
.setNegativeButton(android.R.string.cancel_sign_in, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// This is where you want to remember their choice:
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("declined", true);
editor.commit();
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences prefs = getSharedPreferences("MyAppPrefs", MODE_PRIVATE);
Boolean declined = prefs.getBoolean("declined", false);
if(!declined){
//show dialog again
}
}