Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 220.127.116.11 release ready!
Updated 14 December 2016
The Facebook SDK for Android enables people to sign into your app with Facebook Login. When people log into your app with Facebook they can grant permissions to your app so you can retrieve information or perform actions on Facebook on their behalf.
There are two ways to implement Facebook login on Android:
There are other classes you use to add login to your app. The SDK includes:
Sample Activity to implement login using Facebook Android SDK.
1. Add Compile dependency in build.gradle:
2. Initialize FacebookSdk and setup facebook’s CallbackManager
If you use the LoginButton in a fragment, you need to set the fragment on the button as shown by calling setFragment.
You then need to call FacebookSdk.initialize to initialize the SDK, and then call CallbackManager.Factory.create to create a callback manager to handle login responses. Here’s an example of adding the callback in a fragment:
To respond to a login result, you need to register a callback with either LoginManager or LoginButton. If you register the callback with LoginButton, don’t need to register the callback on Login manager.
You add the callback to your activity or fragment’s onCreate() method:
Layout used in the activity: main.xml
4. On successfull Login
If login succeeds, the LoginResult parameter has the new AccessToken, and the most recently granted or declined permissions.
You don’t need a registerCallback for login to succeed, you can choose to follow current access token changes with the AccessTokenTracker class described below.
Then in onActivityResult() forward the login results to the callbackManager created in onCreate():
Note: Every activity and fragment that you integrate with the FacebookSDK Login or Share should forward onActivityResult to the callbackManager.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.