我试图显示登录到我的应用程序的用户的个人资料图片。这是一个简单的应用程序,只需登录某人,并在登录成功后启动logout
活动。活动中,想显示一个值得欢迎的消息和user.So的图片为止,我已经得到了欢迎信息由MainActivity
定义onConnected()
方法如此工作:使用意图显示Google+个人资料图片
public void onConnected(Bundle connectionHint) {
String accountName = mPlusClient.getAccountName();
Toast.makeText(this, accountName + " is connected.", Toast.LENGTH_LONG).show();
Intent startLogoutActivityIntent = new Intent(this, LogoutActivity.class);
startLogoutActivityIntent.putExtra("ACCOUNT_NAME", accountName);
if (mPlusClient.getCurrentPerson() != null) {
Person currentPerson = mPlusClient.getCurrentPerson();
String personName = currentPerson.getDisplayName();
String photo = currentPerson.getImage().getUrl();
String personGooglePlusProfile = currentPerson.getUrl();
startLogoutActivityIntent.putExtra("Profile_photo", photo);
}
startActivity(startLogoutActivityIntent);
}
,并在我的LogoutActivity
类我加了这几行
TextView message = (TextView) findViewById(R.id.welcomeMessage);
message.setText("Welcome to the DivingScores app " + in.getStringExtra
("ACCOUNT_NAME"));
ImageView profilePicture = (ImageView) findViewById(R.id.userImage);
问题是我不知道用profilePicture
与什么方法打电话。我曾尝试
profilePicture.setImageResource(in.getStringExtra("profile_photo"));
,但我得到的错误
setImageResource (int) in ImageView cannot be applied to (java.lang.String).
可有人请点我在正确的方向?