android - Gettings user events? -


i'm trying user events (one's he's invited to) using fb android sdk have no clue how , i've found no instructions on website.

here's code meanwhile -

import android.content.intent; import android.os.bundle; import android.support.v4.app.fragment; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup;  import com.facebook.request; import com.facebook.response; import com.facebook.session; import com.facebook.sessionstate; import com.facebook.uilifecyclehelper; import com.facebook.model.graphuser; import com.facebook.widget.loginbutton;  public class socigofragmententrance extends fragment {  private final static string tag  = "fb_login";  private uilifecyclehelper uihelper;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      getactivity().getactionbar().hide();      session.statuscallback callback = new session.statuscallback() {         @override         public void call(session session, sessionstate state, exception exception) {             onsessionstatechange(session, state, exception);             request.newmerequest(session, new request.graphusercallback() {                  @override                 public void oncompleted(graphuser user, response response) {                  }             });         }     };       uihelper = new uilifecyclehelper(getactivity(), callback);      uihelper.oncreate(savedinstancestate);   }  @override public view oncreateview(layoutinflater inflater, viewgroup parent         , bundle savedinstancestate) {      view v = inflater.inflate(r.layout.fragment_entrance, parent, false);        loginbutton fbbutton = (loginbutton)v.findviewbyid(r.id.authbutton);      fbbutton.setapplicationid(getresources().getstring(r.string.app_id));     fbbutton.setreadpermissions(new string[]{"user_events", "user_interests", "user_likes"});     fbbutton.setfragment(this);      return v; }  private void onsessionstatechange(session session, sessionstate state, exception exception) {     if (state.isopened()) {         log.i(tag, "logged in...");     } else if (state.isclosed()) {         log.i(tag, "logged out...");     } }    @override public void onactivityresult(int requestcode, int resultcode, intent data) {     super.onactivityresult(requestcode, resultcode, data);     uihelper.onactivityresult(requestcode, resultcode, data); }   @override public void onpause() {     super.onpause();     uihelper.onpause(); }  @override public void onresume() {     super.onresume();      session session = session.getactivesession();     if (session != null &&            (session.isopened() || session.isclosed()) ) {         onsessionstatechange(session, session.getstate(), null);     }      uihelper.onresume(); }  @override public void ondestroy() {     super.ondestroy();     uihelper.ondestroy(); }   @override public void onsaveinstancestate(bundle outstate) {     super.onsaveinstancestate(outstate);     uihelper.onsaveinstancestate(outstate); }  } 

working on while i've figured out how it.

import org.json.jsonobject;  import android.content.intent; import android.os.bundle; import android.support.v4.app.fragment; import android.util.log; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.widget.toast;  import com.facebook.httpmethod; import com.facebook.request; import com.facebook.response; import com.facebook.session; import com.facebook.sessionstate; import com.facebook.uilifecyclehelper; import com.facebook.model.graphuser; import com.facebook.widget.loginbutton;  public class fragmententrance extends fragment {      private final static string tag = "";      private uilifecyclehelper uihelper;     private string fqlquery;      //this reason has variable     private session.statuscallback callback = new session.statuscallback() {         @override         public void call(session session, sessionstate state,                 exception exception) {             onsessionstatechange(session, state, exception);         }     };      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          getactivity().getactionbar().hide();         this.setretaininstance(true);              //reset query         fqlquery = "empty";          uihelper = new uilifecyclehelper(getactivity(), callback);         uihelper.oncreate(savedinstancestate);        }      @override     public view oncreateview(layoutinflater inflater, viewgroup parent,             bundle savedinstancestate) {          view v = inflater.inflate(r.layout.fragment_entrance, parent, false);          loginbutton fbbutton = (loginbutton) v.findviewbyid(r.id.authbutton);              //get permissions         fbbutton.setapplicationid(getresources().getstring(r.string.app_id));         fbbutton.setreadpermissions(new string[] { "user_events",                 "user_interests", "user_likes" });         fbbutton.setfragment(this);          return v;     }      private void onsessionstatechange(final session session,             sessionstate state, exception exception) {         if (state.isopened()) {             log.i(tag, "user logged in."); //here user's id , use query             if (state != sessionstate.opened) {                 request.newmerequest(session, new request.graphusercallback() {                      // callback after graph api response user object                     @override                     public void oncompleted(graphuser user, response response) {                         if (user != null) {                             fqlquery = "select eid event_member start_time >= now() , uid = '"                                     + user.getid() + "'";                             bundle params = new bundle();                             params.putstring("q", fqlquery);                              log.d(tag, fqlquery);                             request request = new request(session, "/fql",                                     params, httpmethod.get,                                     new request.callback() {                                         public void oncompleted(                                                 response response) {                                             if (response.geterror() == null) {                                                 //do things data                                             } else {                                                 toast.maketext(                                                         getactivity(),                                                         "loading events failed.",                                                         toast.length_long)                                                         .show();                                             }                                          }                                     });                             request.executebatchasync(request);                          }                     }                 }).executeasync();             }           } else if (state.isclosed()) {             log.i(tag, "logged out...");         }     }      @override     public void onactivityresult(int requestcode, int resultcode, intent data) {         super.onactivityresult(requestcode, resultcode, data);         uihelper.onactivityresult(requestcode, resultcode, data);     }      @override     public void onpause() {         super.onpause();         uihelper.onpause();     }      @override     public void onresume() {         super.onresume();          session session = session.getactivesession();         if (session != null && (session.isopened() || session.isclosed())) {             onsessionstatechange(session, session.getstate(), null);         }          uihelper.onresume();     }      @override     public void ondestroy() {         super.ondestroy();         uihelper.ondestroy();     }      @override     public void onsaveinstancestate(bundle outstate) {         super.onsaveinstancestate(outstate);         uihelper.onsaveinstancestate(outstate);     }        } 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -