android - Facebook SDK4.0 Login using custom view -
i want log in user inside app using new facebook sdk custom view. here fragment
's oncreateview()
:
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { mview = inflater.inflate(r.layout.fragment_login, container, false); linearlayout facebook = (linearlayout) mview.findviewbyid(r.id.facebook_button); facebook.setonclicklistener(new facebookloginlistener()); loginmanager.getinstance().registercallback(mcontext.mfacebookcallbackmanager, new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { // app code log.d("resultado", "success"); } @override public void oncancel() { // app code log.d("resultado", "cancel"); } @override public void onerror(facebookexception exception) { // app code log.d("resultado", exception.tostring()); } }); return mview; } @override public void onattach(activity activity) { mcontext = (mainactivity) activity; super.onattach(activity); } public class facebookloginlistener implements view.onclicklistener { @override public void onclick(view view) { loginmanager.getinstance().loginwithreadpermissions( loginfragment.this, arrays.aslist("email")); } }
and on mainactivity
@override protected void oncreate(bundle savedinstancestate) { facebooksdk.sdkinitialize(getapplicationcontext()); setcontentview(r.layout.activity_main); mfacebookcallbackmanager = callbackmanager.factory.create(); } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); mfacebookcallbackmanager.onactivityresult(requestcode, resultcode, data); }
the facebook login activity shows i'm not getting callback... correct way implement login?
Comments
Post a Comment