Implementing Facebook Login Using Android SDK
Facebook Login allows you to obtain a token to access Facebook's API on behalf of someone using your app. You can use this feature in place of building your own account system or to add Facebook services to your existing accounts.
To properly handle Facebook Login using the Facebook for Android app, make the following changes in the App Dashboard.
Create a Facebook App
URL to create FB App:
Once created, note down the app ID shown at the top of the dashboard page. You'll need to add this to your project files.
Next, you will also need to associate your Android keys hashes with the app. The key hash is used by Facebook as a security check for authenticity. By default, the app's package is signed with a machine specific debug key. When publishing the app it is typically signed with a different, release key. Therefore, you want to make sure you have the hashes of all the related keys set on Facebook:
Go to 'Settings' in the left nav, then click on the 'Add Platform' button, and select Android. Add the debug key hash that you obtained at the end of the previous step with the keytool app:
If you have a release key, you will need to add its hash in the same way. To obtain the release key hash, use the 'keytool' in the same way as in the steps above except for the alias and path. On OS X, run:
On Windows, use:
Make sure to use the password that you set when you first created the release key.
Save this change.
You will also need to return to this dashboard and add your app's package name and main activity class once you have created a new Android project itself.
If you don’t have openssl please download from below location:
Command to create App ID: [Example]
keytool -exportcert -alias quesponkey -keystore "C:\Users\Sujay.A\Documents\quespon\keystore.keystore" | "C:\Users\Sujay.A\Documents\ Facebook_RND\openssl-0.9.8k_X64\bin\openssl.exe" sha1 -binary | "C:\Users\Sujay.A\Documents\ Facebook_RND\openssl-0.9.8k_X64\bin\openssl.exe" base64
Download Facebook SDK from below location:
Import the SDK into Eclipse
Select only FacebookSDK from that and import that.
Create a new Android Project with Facebook Login
Create a new Android Application Project in Eclipse, using 'File' > 'New' > 'Project...' and select 'Android Application Project':
Finish the wizard, and your new project will have been created, along with the main activity class:
At this point, you should return to the App Dashboard on the Facebook Developers site and add your Android app's package and activity names. To do this, in the app dashboard, go to 'Settings' on the left nav and there, in the Android section, complete the two missing fields. Also enable 'Single Sign On':
Returning to Eclipse, your new application needs to be linked to the SDK library project. View the properties for the project, and navigate to the 'Android' tab. In the lower part of the dialog, click 'Add' and choose the 'FacebookSDK' project from the workspace:
To add the Facebook app ID into your project, open up the
strings.xmlfile in the
res/valuesfolder of your project. You need to add an
app_idstring containing the ID you obtained in the previous step.
(If you view the source of the
strings.xmlfile, you will see the resulting
<string name="app_id">497906953566757</string>in the document.)
Next, open the
AndroidManifest.xmlfile in the root of the project. Add a 'Uses Permission' item named
Also, in the 'Application' tab, add a 'Meta Data' item called
com.facebook.sdk.ApplicationId, with a value of the
app_idstring you just configured:
Finally, add a new Activity to the app, with the name
(Again, if you check the source of the file, you should see the three corresponding new lines in the XML,
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>, and