我想在我的应用程序中登录Google Plus.我可以连接但无法获取当前用户的个人资料信息
@Override public void onConnected() { String accountName = mPlusClient.getAccountName(); mPlusClient.loadPerson(this,"me"); } @Override public void onPersonLoaded(ConnectionResult status,Person person) { Log.d("onPersonLoaded - ConnectionResult","" + status); Log.d("onPersonLoaded - person","" + person); if (status.getErrorCode() == ConnectionResult.SUCCESS) { Log.d(TAG,"Display Name: " + person.getDisplayName()); } }
我可以在onConnected中获取帐户名称但onPersonLoaded为人员提供null
日志显示:
onPersonLoaded - ConnectionResult(29861): ConnectionResult{statusCode=NETWORK_ERROR,resolution=null} onPersonLoaded - person(29861): null
来自文档here
public static final int NETWORK_ERROR
A network error occurred. Retrying should resolve the problem.
Constant Value: 7 (0x00000007)
但无论我重试多少次,我都会得到同样的错误.这些是我使用的权限:
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_PROFILE" />
解决方法
最后我找到了答案.