There are millions of ways to recover this Key Hash.
It serves to identify that only your project is accessing the user's Facebook information as a form of security.
I always broke my mind to recover this key, but I learned a very simple way to do it.
Within the onCreate method, place 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, in your LogCat (Android Monitor), will appear a code something like this:
KeyHash: nzM5O1NWEmtflcC3vDK2lx3CwcM=
All these numbers and letters are your Hash Key, including the = sign , then you can put it in the Facebook control panel, so that it recognizes your application.