Go to Facebook developer console:- Facebook Developer Console and create an app, enter all description, images, banner in App Details and put it into live mode in Status & Review . After that go to Dashboard and click on Getting Started button and select Android and than follow the given steps there. Download Facebook Android SDK, generate hash, put all info there. Some basic questions:-
Question:- How to generate hash?
Answer:- Download openssl.exe from official site or from code.google.com (I downloaded from official site)and unzip it. Open command prompt and type below command to generate hash:
keytool -exportcert -alias mykey -keystore %HOMEPATH%\.android\debug.keystore | "C:\openssl\openssl.exe" sha1 -binary | "C:\openssl\openssl.exe" base64
cmd will ask password than generate hash and in my case, openssl.exe was in C:\openssl\ directory so change it accordingly. Copy your app id and now you have all done from Facebook side.
Open facebook project module and define a string "facebook_app_id" in string.xml file.
change it with your app id. now change manifest file of Facebook project:-
You have done from facebook project module and now move to your main project. Go to file -> project structure -> dependency -> add facebook.
Now open your layout file and add a button for facbook login and assign id name "bt_facebook" than use below code in your activity for Facebook login and user details:-
To logout from Facebook:-
To get current Access Token:-
In this post, I used custom button for login, you all can use official Facebook button. Don't forget to share this post. If you have any question regarding this post than feel free to comment.
★ Add Google AdMob Ads in Android App & Earn Money
★ Advance Android Google Map 2 Tutorial with Examples - Part 1
★ Start Working on Linphone Android
★ Easy Reader: Gesture controlled TextView (With Pinch to Zoom)
★ Android Twitter Fabric SDK Integration with user details in Android Studio