android - Unable to retrieve email address from Facebook API -
i getting null pointer exception while getting email address facebook api on android 3.0.
the code generating exception below:
loginbutton authbutton; authbutton = (loginbutton) findviewbyid(r.id.authbutton); // set permission list, don't forget add email authbutton.setreadpermissions(arrays.aslist("basic_info", "email")); authbutton.setsessionstatuscallback(new session.statuscallback() { @override public void call(session session, sessionstate state, exception exception) { showtoast("inside call"); if (session.isopened()) { showtoast("inside session"); system.out.println("facebook access token" + session.getaccesstoken()); fbtoken = session.getaccesstoken(); request.executemerequestasync(session, new request.graphusercallback() { @override public void oncompleted(graphuser user, response response) { if (user != null) { string email = user.asmap().get("email").tostring(); } } }); } } });
the code working - might have made mistake while integrating code.
you can user email graphuser object using property.
user.getproperty("email").tostring()
it works me.hoping work you.
Comments
Post a Comment