android - Facebook 3.0 issue with login -
i trying understand how facebook 3.0 sdk login proccess working. walked through this tutorial. every thing works fine, how should continue? lets after loging in want users email or navigate other activity. should put code in case. have mainactivity code:
package com.shaleapp.activities; import android.app.activity; import android.content.intent; import android.os.bundle; import android.support.v4.app.fragmentactivity; import android.util.log; import android.view.menu; import android.widget.textview; import com.facebook.request; import com.facebook.response; import com.facebook.session; import com.facebook.sessionstate; import com.facebook.model.graphuser; import com.parse.parsefacebookutils; import com.shale.fragments.mainfragment; import com.shaleapp.services.init; import com.shaleapp.shale.r; public class mainactivity extends fragmentactivity { private mainfragment mainfragment; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); if (savedinstancestate == null) { // add fragment on initial activity setup mainfragment = new mainfragment(); getsupportfragmentmanager().begintransaction().add(android.r.id.content, mainfragment).commit(); } else { // or set fragment restored state info mainfragment = (mainfragment) getsupportfragmentmanager().findfragmentbyid(android.r.id.content); } } @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); session.getactivesession().onactivityresult(this, requestcode, resultcode, data); //parsefacebookutils.finishauthentication(requestcode, resultcode, data); } @override public boolean oncreateoptionsmenu(menu menu) { //inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } }
and mainfragment code:
package com.shale.fragments; 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.session; import com.facebook.sessionstate; import com.facebook.uilifecyclehelper; import com.facebook.widget.loginbutton; import com.shaleapp.shale.r; public class mainfragment extends fragment { private static final string tag = "mainfragment"; private uilifecyclehelper uihelper; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.main, container, false); loginbutton authbutton = (loginbutton) view.findviewbyid(r.id.authbutton); authbutton.setfragment(this); return view; } private void onsessionstatechange(session session, sessionstate state, exception exception) { if (state.isopened()) { log.w(tag, "logged in..."); } else if (state.isclosed()) { log.w(tag, "logged out..."); } } 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); uihelper = new uilifecyclehelper(getactivity(), callback); uihelper.oncreate(savedinstancestate); } @override public void onresume() { super.onresume(); // scenarios main activity launched , user // session not null, session state change notification // may not triggered. trigger if it's open/closed. session session = session.getactivesession(); if (session != null && (session.isopened() || session.isclosed()) ) { onsessionstatechange(session, session.getstate(), null); } uihelper.onresume(); } @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 ondestroy() { super.ondestroy(); uihelper.ondestroy(); } @override public void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); uihelper.onsaveinstancestate(outstate); } }
i trying debug couldn't find point mainfragment returns session or other object mainactivity
after login when fb screens opens it's going onactivityresult
.
when session state changes got inside session.statuscallback
.
see values of sessionstate
, if got exception receive there.
if you'll more specific i'll able answer more details.
Comments
Post a Comment