我做了Facebook登錄,但我不知道如何獲得電子郵件地址,並以另一種形式Android開Facebook的電子郵件地址
所以顯示出來,這是代碼
private void nextActivity(Profile profile){
if(profile != null){
Intent main = new Intent(LogInTo.this, SetUsername.class);
main.putExtra("name", profile.getFirstName());
main.putExtra("surname", profile.getLastName());
//main.putExtra("email", profile.get());
main.putExtra("imageUrl",
profile.getProfilePictureUri(200,200).toString());
startActivity(main);
finish();
}
}
這是我的回調
LoginButton loginButton = (LoginButton)findViewById(R.id.loginButton);
FacebookCallback<LoginResult> callback = new
FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Profile profile = Profile.getCurrentProfile();
nextActivity(profile);
Toast.makeText(getApplicationContext(), "Logging in...", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException e) {
}
};
loginButton.setReadPermissions(Arrays.asList("user_friends"));
loginButton.registerCallback(callbackManager, callback);
而且這是你從Facebook獲得的電子郵件地址顯示在另一種形式的代碼
Bundle inbundle = getIntent().getExtras();
String name = inbundle.get("name").toString();
String surname = inbundle.get("surname").toString();
FbFullname = (EditText) findViewById(R.id.fbfullname);
FbFullname.setText("" + name + " " + surname);
FbUsername = (EditText) findViewById(R.id.fbusername);
FbType = (EditText) findViewById(R.id.fbtype);
FbEmail = (EditText) findViewById(R.id.fbemail);
你沒有問用戶權限讀取他們的電子郵件。 – CBroe
我應該在這裏添加嗎? loginButton.setReadPermissions(Arrays.asList(「user_friends」)); –
Sharmaine Shane Amansec Cinens你已經收到郵件了嗎?我也有這個問題 –