There are a million ways to retrieve this Key Hash.
It serves to identify that only your project is accessing the user’s Facebook information, as security even.
I always broke my head to get that key back, but I learned a very simple way to do it.
Within the onCreate method, enter this code:
try {
PackageInfo info = getPackageManager().getPackageInfo(
getPackageName(),
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
}
catch (NameNotFoundException e) {
}
catch (NoSuchAlgorithmException e) {
}
Now run your application, on your Logcat (Android Monitor), will appear a code more or less like this:
KeyHash: nzM5O1NWEmtflcC3vDK2lx3CwcM=
All these numbers and letters are your Hash Key, including the sign of =, then you put it on the Facebook control panel, so it recognizes your application.
Which error occurred ?
– Marco Souza
"'keytool' is not recognized as an internal & #Xa; or external command, a operable program, or a batch file."
– Leila