In Android, Facebook API V2.4 is not returning email id whereas V2.3 is returning. How to get email id in V2.4? -


when wrote following code api v2.3 giving me details including email id. , same code not giving me email id. can can email id?

    oncreate(..)     {     .     .         email_permission = new arraylist<string>();     email_permission.add("email");     uilifecyclehelper = new uilifecyclehelper(this, statuscallback);      uilifecyclehelper.oncreate(savedinstancestate);     session.openactivesession(this, true, email_permission,                                              statuscallback);     // callback when session changes state session.statuscallback statuscallback = new statuscallback() {     @override     public void call(session session, sessionstate state, exception                                                            exception)     {          // checking whether session opened or not         if (state.isopened())         {         } else         {             if (state.isclosed())             {             }             log.d(tag, state.tostring());         }     } };  // method user facebook profile void getuserfacebookprofile(session session, final boolean finish) {     // checking whether session opened or not     if (session.isopened())     {         // sending request facebook user facebook profile         request.newmerequest(session, new graphusercallback()         {              @override             public void oncompleted(graphuser user, response response)             {                  if (user != null)                 {                     // network user id                     string networkuserid = user.getid();                     // user first name                     string fname = user.getfirstname();                     // user last name                     string lname = user.getlastname();                     // user middle name                     string mname = user.getmiddlename();                 // string email = user.getproperty("email").tostring();     string email = response.getgraphobject().getproperty("email")                      .tostring();                 } 

now above code gave me details including email id v2.3, i'm not able email id. please let me know solution. thanks.

public class loginfacebook {     callbackmanager callbackmanager;     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);          facebooksdk.sdkinitialize(getapplicationcontext());         callbackmanager = callbackmanager.factory.create();       public void openfb() {             loginmanager.getinstance().loginwithreadpermissions(activity,                     arrays.aslist("read_stream", "user_photos", "email", "user_location"));              // login callback registration             loginmanager.getinstance().registercallback(callbackmanager, new facebookcallback<loginresult>() {                  @override                 public void onsuccess(final loginresult loginresult) {                     new graphrequest(accesstoken.getcurrentaccesstoken(),                             "/me", null, httpmethod.get,                             new graphrequest.callback() {                                 public void oncompleted(                                         graphresponse response) {                                     /* handle result */                                      try {                                         //get user information                                         jsonobject json = response.getjsonobject();                                         string email = json.getstring("email");                                         string fullname = json.getstring("name");                                         string accesstoken = loginresult.getaccesstoken().gettoken();                                         int type = 1;                                         string lastupdate = json.getstring("updated_time");                                         string user_id = json.getstring("id");                                      } catch (jsonexception e) {                                         // todo auto-generated catch block                                         e.printstacktrace();                                     } catch (ioexception e) {                                         // todo auto-generated catch block                                         e.printstacktrace();                                     }                                 }                             }).executeasync();                      getsnspost getsnspost = getsnspost.getinstance(activity);                     getsnspost.getfacebookposts();                  }                  @override                 public void oncancel() {                  }                  @override                 public void onerror(facebookexception exception) {                  }             });          }       public void loginfacebook(view v){            openfb();      }      protected void onactivityresult(final int requestcode, final int resultcode, final intent data) {         callbackmanager.onactivityresult(requestcode, resultcode, data);      }     } 

since session have been deprecated long time ago, don't use anymore. user information way. hope code solve problem ;)


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -