android - How can I use the LoginManager class from FacebookSDK inside a Fragment? -
it looks loginmanager facebooksdk contains method android.support.v4.app.fragment parameter, , none android.app.fragment. unfortunately, v4.app.fragment not option me. have tried doing same thing in activity , in v4.app.fragment, , works. however, cannot use either of those.
private void init() { callbackmanager = callbackmanager.factory.create(); loginmanager = loginmanager.getinstance(); loginmanager.registercallback(callbackmanager, new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { onloginsuccess(loginresult); } @override public void oncancel() { onloginfailed(); } @override public void onerror(facebookexception e) { onloginfailed(); } }); } private void login() { global.log("logging in facebook"); collection<string> permissions = arrays.aslist("public_profile", "email"); loginmanager.loginwithreadpermissions(getactivity(), permissions); } @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); callbackmanager.onactivityresult(requestcode, resultcode, data); }
the method in question loginmanager.loginwithreadpermissions, can take either activity or v4.app.fragment parameter, not type of fragment need.
can help?
it implemented in facebook sdk version 4.8.0 (nov 11, 2015), take look:
added support using login manager , ui elements native fragments (android.app.fragment)
and documentation has been updated well:
callbackmanager - use route calls facebook sdk , registered callbacks. should call initiating activity or fragments onactivityresult call.
sources:
https://developers.facebook.com/docs/facebook-login/android https://developers.facebook.com/docs/android/change-log-4.x#4_8_0
Comments
Post a Comment