Generate key hash for Android Facebook Login
When you activate a new app in Facebook for android you will need a key hash. You can use this code fragment for generating the key hash.
try {
PackageInfo info = getPackageManager().getPackageInfo(
"Your package name",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("TAG_KEY_HASH", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
Use ctrl+shift+o to import classes,
then Run the project and you need to find out the TAGKEYHASH in LogCat
Written by Leonel Mendez Jimenez
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Android
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#