Trouble generating keyhash for Facebook SDK integration with your application, here is the java code to generate keyhash.
Add the following code inside onCreate()
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());
System.out.println("KeyHash : "+ Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
NOTE: Do not forget to replace YOUR_PACKAGE_NAME with your Main activity package name. After running the application you will find the key hash in LogCat.
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!