Issues Creating Login Button Using Facebook SDK 4.1.2
Solution 1:
I don't see in your code onActivityResult
method. It is required for properly SDK workflow.
You need to add it to the MainActivity:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
Cause:
Every activity and fragment that you integrate with the FacebookSDK Login or Share should forward onActivityResult to the callbackManager.
You can find it in documentation here.
Solution 2:
The issue may arise due to non-initialization of FacebookSdk before its usage. Try initializing facebook sdk before :
1.setContentView(R.layout.activity_main); (In Activity)
2.View rootView = inflater.inflate(R.layout.facebook_fragment, parentViewGroup, false); (In fragment)
Hope this helps!
Solution 3:
Make sure you initialized facebook SDK before inflater.
FacebookSdk.sdkInitialize(getActivity());
View rootView = inflater.inflate(R.layout.facebook_fragment, parentViewGroup, false);
Solution 4:
You initialized facebook sdk in both MainActivity and FacebookFragment, that is not needed, only once is enough and you better initialize it in the superclass, here probably in your MainActivity.
Remove this line FacebookSdk.sdkInitialize(getActivity());
from FacebookFragemet,
and swap lines as follows in MainActivity
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_main);
Post a Comment for "Issues Creating Login Button Using Facebook SDK 4.1.2"