我正在调用 GoogleApiClient Api 以获取有关当前用户的一些基本个人资料信息(例如性别)。
我可以在不要求用户显式登录的情况下完成此操作吗?
这是我的代码:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_PROFILE)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.setAccountName("myemail@example.com")
.build();
然后我打电话mGoogleApiClient.connect();
onConnectionFailed 被调用,并带有以下消息:
GoogleApiClient: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{2148816a: android.os.BinderProxy@549965b}}
到目前为止,我已经设置了这些权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />