I'm working on an Android app, in which I want to integrate a Facebook posting feature. I downloaded the Facebook-Android SDK, and I got the readme.md (text file) in there, in which it is mentioned to generate the key hash for Android. How do I generate it?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
download openSSL for windows in here you can find 64bit and 32bit here
extract the downloaded file
This is what is given at the official page of Facebook:
Let me break this command into fragments.
Look for
"keytool.exe"
. You can search that on the C: drive. You can find it in"java jdk"
or"java jre"
. If you have installed multiple versions, choose any.Open a CMD prompt and go to the above directory where you found
"keytool.exe"
.Clip the "exe`" and paste the above command provided on the Facebook page.
You will get an error on entering this that OpenSSL is not recognized as in input output command. Solution : Download "Openssl" from OpenSSL (if you have a 64-bit machine you must download openssl-0.9.8e X64). Extract and save it anywhere... I saved it on the C: drive in the
OpenSSl
folderReplace the openssl in the above command in which you was getting an error of OpenSSL with "C:\OpenSSL\bin\openssl" at both the places after the pipe, "|".
If prompted for a password, enter
android
.And you will get your hash key. For further steps, refer again to the Facebook page.
For an Android application
This code is used to get the hash key in your Android application for Facebook integration. I have tested all devices and it's working. Only change the package name of this code:
You need to create a keystore by the keytool for signed apps for android like the procedure described in Android Site and then you have to install cygwin and then you need to install openssl from google code then just execute the following command and you will get the hash key for android and then put that hash key into the facebook application you created. And then you can access the facebook application through the Android Application for posting wall ("publish_stream") could be an example.
$ keytool -exportcert -alias alias_name -keystore sample_keystore.keystore | openssl sha1 -binary | openssl base64
You need to execute the above command from cygwin.
You can use this code in any activity. It will log the hashkey in the logcat, which is the debug key. This is easy, and it's a relief than using SSL.
You can delete the code after knowing the key ;)
I did a small mistake that should be kept in mind. If you are using your keystore then give your alias name, not androiddebugkey...
I solved my problem. Now if Facebook is there installed in my device, then still my app is getting data on the Facebook login integration. Just only care about your hash key.
Please see below.
Then press Enter - it will ask you for the password and then enter your keystore password, not Android.
Cool.