【发布时间】:2014-11-20 05:02:33
【问题描述】:
我正在尝试访问 google+ 用户个人资料并获取他的详细信息,例如姓名、电子邮件和个人资料图片,如下所示:
public void onConnected(Bundle connectionHint) {
// We've resolved any connection errors. mGoogleApiClient can be used to
// access Google APIs on behalf of the user.
mSignInClicked = false;
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Intent i = new Intent(getApplicationContext(), MainActivity.class);
Person currentPerson = Plus.PeopleApi
.getCurrentPerson(mGoogleApiClient);
String personPhotoUrl = currentPerson.getImage().getUrl();
String personGooglePlusProfile = currentPerson.getUrl();
personPhotoUrl = personPhotoUrl.substring(0,
personPhotoUrl.length() - 2)
+ PROFILE_PIC_SIZE;
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
Bitmap image = BitmapFactory.decodeFile(personPhotoUrl);
i.putExtra("Google", "Logged in using Google Account");
i.putExtra("GoogleUsername", currentPerson.getDisplayName());
i.putExtra("GoogleEmail", email);
i.putExtra("GoogleProfileImage", image);
startActivity(i);
}
我可以获取姓名、电子邮件,但无法获取他的个人资料照片。
这就是我将个人资料照片发送到下一个活动的方式:
Bitmap bitmap = (Bitmap)this.getIntent().getParcelableExtra("GoogleProfileImage");
ImageView imageView = (ImageView) findViewById(R.id.imgProfilePic);
imageView.setImageBitmap(bitmap);
谁能告诉我如何获取个人资料图片并将其发送到我的下一个活动?
【问题讨论】:
标签: android image android-activity google-plus user-profile