[英]Why can't I read account information?
I am totally new in Web API's and am trying to build an Android application for watching google contacts.我是 Web API 的新手,我正在尝试构建一个用于观看谷歌联系人的 Android 应用程序。 I'm stuck on a first step with OAuth.
我被困在 OAuth 的第一步。 I'm done with sign in button and authorization.
我完成了登录按钮和授权。 Button works correct and I can sign in my Google account, but when I'm trying to get something from this account logcat printing this massage "I/system_server: oneway function results will be dropped but finished with status OK and parcel size".
按钮工作正常,我可以登录我的 Google 帐户,但是当我尝试从该帐户中获取某些内容时,logcat 会打印此消息“I/system_server: oneway 函数结果将被删除,但已完成状态 OK 和包裹大小”。 Why is this happen?
为什么会发生这种情况? Becouse auth token is no longer valid?
因为身份验证令牌不再有效? How to restore permission?
如何恢复权限? How should I get information from account?
我应该如何从帐户中获取信息?
This is code:这是代码:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestServerAuthCode(clientID).requestEmail().requestScopes
(new Scope("https://www.googleapis.com/auth/contacts "))
.build();
mSignInClient = GoogleSignIn.getClient(this, gso);
signInButton = findViewById(R.id.sign_in_button);
getInfoButton = findViewById(R.id.getInfo);
signInButton.setSize(SignInButton.SIZE_STANDARD);
signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.sign_in_button:
signIn();
break;
}
}
});
private void signIn(){
Intent intent = mSignInClient.getSignInIntent();
startActivityForResult(intent, RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task =
GoogleSignIn.getSignedInAccountFromIntent(data);
if (task.isSuccessful()) {
GoogleSignInAccount acct = task.getResult();
account = acct;
handleSignInResult(task);
} else {
}
}
}
And this how i trying to get info from account:这就是我尝试从帐户获取信息的方式:
private void getAccountInfo(){
GoogleSignInAccount acct = GoogleSignIn.getLastSignedInAccount(this);
if (acct != null) {
String personName = acct.getDisplayName();
String personGivenName = acct.getGivenName();
String personFamilyName = acct.getFamilyName();
String personEmail = acct.getEmail();
String personId = acct.getId();
Uri personPhoto = acct.getPhotoUrl();
Log.d(TAG, acct.getDisplayName());
Log.d(TAG, personGivenName);
Log.d(TAG, personFamilyName);
}
}
And what about AccountManager?那么 AccountManager 呢? Should I use it?
我应该使用它吗? I would be glad to receive any information.
我很高兴收到任何信息。
I am totally new in Web API's and am trying to build an Android application for watching google contacts.我是 Web API 的新手,我正在尝试构建一个用于观看谷歌联系人的 Android 应用程序。 I'm stuck on a first step with OAuth.
我被困在 OAuth 的第一步。 I'm done with sign in button and authorization.
我完成了登录按钮和授权。 Button works correct and I can sign in my Google account, but when I'm trying to get something from this account logcat printing this massage "I/system_server: oneway function results will be dropped but finished with status OK and parcel size".
按钮工作正常,我可以登录我的 Google 帐户,但是当我尝试从该帐户中获取某些内容时,logcat 会打印此消息“I/system_server: oneway 函数结果将被删除,但已完成状态 OK 和包裹大小”。 Why is this happen?
为什么会发生这种情况? Becouse auth token is no longer valid?
因为身份验证令牌不再有效? How to restore permission?
如何恢复权限? How should I get information from account?
我应该如何从帐户中获取信息?
This is code:这是代码:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestServerAuthCode(clientID).requestEmail().requestScopes
(new Scope("https://www.googleapis.com/auth/contacts "))
.build();
mSignInClient = GoogleSignIn.getClient(this, gso);
signInButton = findViewById(R.id.sign_in_button);
getInfoButton = findViewById(R.id.getInfo);
signInButton.setSize(SignInButton.SIZE_STANDARD);
signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.sign_in_button:
signIn();
break;
}
}
});
private void signIn(){
Intent intent = mSignInClient.getSignInIntent();
startActivityForResult(intent, RC_SIGN_IN);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task =
GoogleSignIn.getSignedInAccountFromIntent(data);
if (task.isSuccessful()) {
GoogleSignInAccount acct = task.getResult();
account = acct;
handleSignInResult(task);
} else {
}
}
}
And this how i trying to get info from account:这就是我尝试从帐户获取信息的方式:
private void getAccountInfo(){
GoogleSignInAccount acct = GoogleSignIn.getLastSignedInAccount(this);
if (acct != null) {
String personName = acct.getDisplayName();
String personGivenName = acct.getGivenName();
String personFamilyName = acct.getFamilyName();
String personEmail = acct.getEmail();
String personId = acct.getId();
Uri personPhoto = acct.getPhotoUrl();
Log.d(TAG, acct.getDisplayName());
Log.d(TAG, personGivenName);
Log.d(TAG, personFamilyName);
}
}
And what about AccountManager?那么 AccountManager 呢? Should I use it?
我应该使用它吗? I would be glad to receive any information.
我很高兴收到任何信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.