Facebook login in fragment in android

android picture android · Jan 12, 2016 · Viewed 10k times · Source

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 ??

Answer

Shoeb Siddique picture Shoeb Siddique · Jan 12, 2016

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);
        }