Last active
August 29, 2015 14:09
-
-
Save SpiritOfDarkDragon/7b70143b498a46529d3b to your computer and use it in GitHub Desktop.
Facebook error : allow key: configure your app key hashes at dev.facebook android. Solved!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Goto: https://developers.facebook.com/apps, Settings, Add platform "Android", input Key Hashes of your app. | |
public static String printKeyHash(Activity context) { | |
PackageInfo packageInfo; | |
String key = null; | |
try { | |
//getting application package name, as defined in manifest | |
String packageName = context.getApplicationContext().getPackageName(); | |
//Retriving package info | |
packageInfo = context.getPackageManager().getPackageInfo(packageName, | |
PackageManager.GET_SIGNATURES); | |
Log.d("Package Name=", context.getApplicationContext().getPackageName()); | |
for (Signature signature : packageInfo.signatures) { | |
MessageDigest md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
key = new String(Base64.encode(md.digest(), 0)); | |
// String key = new String(Base64.encodeBytes(md.digest())); | |
Log.d("Key Hash=", key); | |
} | |
} catch (PackageManager.NameNotFoundException e1) { | |
Log.d("Name not found", e1.toString()); | |
} | |
catch (NoSuchAlgorithmException e) { | |
Log.d("No such an algorithm", e.toString()); | |
} catch (Exception e) { | |
Log.d("Exception", e.toString()); | |
} | |
return key; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment