PARSING FACEBOOK DATA FOR ANDROID 1
Step by Step Import Android SDK Get the hash key Create a new app Create a new project in Eclipse Setting android layout File Class in Package Folder Edit AndoidManifest.xml Run your app! 2
Import Android SDK Download Android SDK from Import SDK to your workspace 3
Get the Hash Key Download and extract OpenSSL from windows/downloads/detail?name=openssl-0.9.8k_WIN32.zip windows/downloads/detail?name=openssl-0.9.8k_WIN32.zip Get the path location of OpenSSL/bin Get the path location of debug.keystore from android folder C:\Users\User\.android 4
Get the Hash Key (cont.) Open cmd Change root in command line with path location of Java jre. example : Write this command Example : keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64 keytool -exportcert -alias androiddebugkey -keystore “C:\Users\User\.android\debug.keystore”| “C:\OpenSSL\bin\openssl” sha1 -binary | “C:\OpenSSL\bin\openssl” base64 5 Path debug.keystore Path openssl.exe
Get the Hash Key (cont.) Will appear hash key in command line. Save the hash key. 6 Hash key
Create a facebook app Open link facebook developer. Create a New App. 7
Create a facebook app (cont.) Save App ID. We will use the ID in androidmanifest.xml (setting for android) 8
Create a facebook app (cont.) Go to 'Settings' in the left navigation, then click on the 'Add Platform' button, and select Android. Add the debug hash key from previous step. Change button Single Sign On to “Yes” 9
Create New Project in Eclipse When you create new android application, dont’ forget to use package name that you have written when create a facebook app (previous step) Minimum android SDK for facebook API 10
Create New Project in Eclipse (cont.) Right click at the project, then choose Properties Go to ‘Android’ in the left nav and add facebook SDK library 11
Create New Project in Eclipse (cont.) Add tag string app_id from previous step to res/values/string.xml 12
Create New Project in Eclipse (cont.) Copy all file above to your libs folder. We use Parse library from to easier access facebook datawww.parse.com 13
Setting android layout Open /res/layout/main.xml. Edit the code 14 Graphical layout main.xml
Setting android layout (cont.) Make new userdetails.xml file in res/layout 15 Graphical layout userdetails.xml
Setting android layout (cont.) 16
Setting android layout (cont.) 17
File Class in Package Folder Add new LoginActivity class (you can copy the code but dont forget to change package name in first line of the code) This activity will call the facebook login and ask permission from the user. This activity also call parse libraries to parsing data user with JSON. You can setting the data you will access in list permission. For more information facebook data that allowed to access can you see in api/reference/userhttps://developers.facebook.com/docs/graph- api/reference/user 18
File Class in Package Folder (cont.) Add new UserDetailsActivity.java class (you can copy the code but dont forget to change package name in first line of the code) This class is to show result of parsing data. Add new IntegratingFacebookTutorialApplication.java class (you can copy the code but dont forget to change package name in first line of the code) This class will connect Parse Library to your class. 19
Edit AndoidManifest.xml This application need to connect with internet. So you need to add some permission tag The activity must initialize in tag application and add meta-data tag 20
Run the application Now, your application ready to run ! 21