我試圖顯示登錄到我的應用程序的用戶的個人資料圖片。這是一個簡單的應用程序,只需登錄某人,並在登錄成功後啓動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).
可有人請點我在正確的方向?