您好我正在构建一个将采用谷歌个人资料名称的应用程序,然后它将作为EditText显示在另一个活动中。
ActivityGoogle
private void getProfileInformation() {
try {
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi
.getCurrentPerson(mGoogleApiClient);
String personName = currentPerson.getDisplayName();
String personPhotoUrl = currentPerson.getImage().getUrl();
String personGooglePlusProfile = currentPerson.getUrl();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
textView_name.setText(personName);
textView_email.setText(email);
// by default the profile url gives 50x50 px image only
// we can replace the value with whatever dimension we want by
// replacing sz=X
personPhotoUrl = personPhotoUrl.substring(0,
personPhotoUrl.length() - 2)
+ 400;
new LoadProfileImage(imageView_profile_image).execute(personPhotoUrl);
} else {
Toast.makeText(getApplicationContext(),
"Person information is null", Toast.LENGTH_LONG).show();
任何想法如何从中获取名称并在EditText中显示
ActivityUser
profilename = (EditText)findViewbyId(R.id.profilename);
答案 0 :(得分:0)
(我发布它作为评论,但我认为它解决了这个问题,所以我将其作为答案发布并添加一些解释)
此代码取自其中一个链接,这就是您所需要的。它会在Bundle
:
ActivityGoogle
Intent mIntent = new Intent(this, Example.class);
Bundle extras = mIntent.getExtras();
extras.putString(key, value); // <-- key is the same
然后,在ActivityUser
上添加以下内容(请注意key
}中的Activity
变量必须相同:
ActivityUser
String value = getIntent().getExtras().getString(key); // <-- as the key here