尝试将GoogleSignInApi用于我的应用时,它会抛出此execption:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9001, result=-1, data=Intent { (has extras) }}
我不知道这个错误来自哪里,我想知道如何修复它。
到目前为止,我已对此进行了编程:
public void signIn() {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleclient);
startActivityForResult(signInIntent, RC_SIGN_IN);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
if(resultCode == RESULT_OK){
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
}
}
private void handleSignInResult(GoogleSignInResult result) {
Log.d("TAG", "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
if(acct != null){
Log.d("oke", acct.getDisplayName());
}
} else {
}
}
此代码给出了我在标题中提到的错误。 我不知道为什么会这样,在我的其他项目中,一切都在发挥作用。
答案 0 :(得分:0)
简单的错误:
你必须做
setContentView(view);
在初始化GoogleSignInApi!
之前