Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook login in fragment in android

I'm trying to login Facebook using custom interface it worked fine in Activity class. same thing i have to do in Fragment too. but Callback is not executing. is it not possible to add CallbackResult in Fragment's OnActivityResult ??

like image 341
android Avatar asked Jan 12 '16 05:01

android


People also ask

How do I create a Facebook login request?

You can use a six digit text message (SMS) code sent to your mobile phone. By tapping your security key on a compatible device. With a security code from a third party app you've associated with your Facebook account. You can approve your login attempt from a device we already recognize.

How did you integrate the Facebook SDK in Android app?

To use the Facebook SDK in an Android Studio project, add the SDK as a build dependency and import the SDK. Go to Android Studio | New Project | Minimum SDK. Select API 15: Android 4.0. 3 (IceCreamSandwich) or higher and create your new project.


1 Answers

You just need to add this code in your Activity onActivityResult.

for (Fragment fragment : getSupportFragmentManager().getFragments()) {
            //System.out.println("@#@");
            fragment.onActivityResult(requestCode, resultCode, data);
        }

Then your fragment onActivityResult will surely gonna work.

   @Override
        public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {


            callbackManager.onActivityResult(requestCode, resultCode, data);
        }
like image 113
Shoeb Siddique Avatar answered Oct 06 '22 08:10

Shoeb Siddique