Reputation: 10580
i want to add permission to read email
from the facebook android sdk.
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state,
Exception exception) {
// TODO Auto-generated method stub
if (session.isOpened()) {
// make request to the /me API
Request.executeMeRequestAsync(session,
new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user,
Response response) {
if (user != null) {
et_firstName.setText(user
.getFirstName());
et_lastName.setText(user
.getLastName());
Log.e("data",
user.asMap().get("email")
+ "");
URL image_value;
try {
image_value = new URL(
"http://graph.facebook.com/"
+ user.getId()
+ "/picture");
iv_profileImage
.setImageBitmap(BitmapFactory
.decodeStream(image_value
.openConnection()
.getInputStream()));
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else {
}
}
});
}
}
});
I read a lot that this can be done using loginbutton
but i don't want to use loginbutton.
also i read that if i don't want to use logingbutton
, i have to use openfor
session, but i didn't know how to use that
Upvotes: 0
Views: 539
Reputation: 3546
If you use a LoginButton, use:
loginButton.setReadPermissions(Arrays.asList("email"));
If you start the Session yourself, use:
session.openForRead(new Session.OpenRequest(this).setPermissions(Arrays.asList("email")));
requests/permissions helpfull link: https://developers.facebook.com/tools/explorer/
After successfull login, try the request again including the email field.
Upvotes: 1