parsing facebook data for android 1. step by step import android sdk get the hash key create a...
TRANSCRIPT
1
PARSING FACEBOOK DATA FOR ANDROID
2
Step by Step
1. Import Android SDK
2. Get the hash key
3. Create a new app
4. Create a new project in Eclipse
5. Setting android layout
6. File Class in Package Folder
7. Edit AndoidManifest.xml
8. Run your app!
3
Import Android SDK
Download Android SDK from https://developers.facebook.com/docs/android
Import SDK to your workspace
4
Get the Hash Key
Download and extract OpenSSL from https://code.google.com/p/openssl-for-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
5
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
Path debug.keystore Path openssl.exe
6
Get the Hash Key (cont.)
Will appear hash key in command line. Save the hash key.
Hash key
7
Create a facebook app
Open link facebook developer.
Create a New App.
8
Create a facebook app (cont.)
Save App ID. We will use the ID in androidmanifest.xml (setting for android)
9
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”
10
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
11
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
12
Create New Project in Eclipse (cont.)
Add tag string app_id from previous step to res/values/string.xml
13
Create New Project in Eclipse (cont.)
Copy all file above to your libs folder.
We use Parse library from www.parse.com to easier access facebook data
14
Setting android layout
Open /res/layout/main.xml. Edit the code
Graphical layout
main.xml
15
Setting android layout (cont.)
Make new userdetails.xml file in res/layout
Graphical layoutuserdetails.xml
16
Setting android layout (cont.)
17
Setting android layout (cont.)
18
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 https://developers.facebook.com/docs/graph-api/reference/user
19
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.
20
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
<uses-permission android:name="android.permission.INTERNET"/><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
21
Run the application
Now, your application ready to run !