Skip to content

Instantly share code, notes, and snippets.

@ipereziriarte
Created October 17, 2013 10:54
Show Gist options
  • Save ipereziriarte/7022909 to your computer and use it in GitHub Desktop.
Save ipereziriarte/7022909 to your computer and use it in GitHub Desktop.
I had some trouble login in Facebook with the skd 3.4. Finally the problem was that the hash generated by the keytool was different from the hash that the app was using. If you write this snipped of code in the onCreate method of your main activity you'll get the correct hash and then you can write it down in your facebook app control panel
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("TAG", "Hash to copy ==> " + Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (PackageManager.NameNotFoundException e) {
}
catch (NoSuchAlgorithmException e) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment