Last active
January 3, 2016 02:59
-
-
Save saumya/8399013 to your computer and use it in GitHub Desktop.
Android : Print the HashKey required for working with native facebook SDK. On the android project, put this function(copy-paste) on the Main Activity class. Now call this.printFaceBookHash("com.saumya.myNativeApp"); Note: pass on the exact package name of your application. This will print the HashKey on the LogCat output of Eclipse. Not sure if …
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
private void printFaceBookHash(String packageName){ | |
String mAppPackage = packageName; | |
try { | |
PackageInfo info = getPackageManager().getPackageInfo( | |
mAppPackage, PackageManager.GET_SIGNATURES); | |
for (Signature signature : info.signatures) { | |
MessageDigest md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
Log.d("KeyHash:", "===================================================="); | |
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); | |
Log.d("KeyHash:", "===================================================="); | |
} | |
} catch (NameNotFoundException e) { | |
Log.d("NameNotFoundException:", "===================================================="); | |
e.printStackTrace(); | |
Log.d("NameNotFoundException:", "===================================================="); | |
} catch (NoSuchAlgorithmException e) { | |
Log.d("NoSuchAlgorithmException:", "===================================================="); | |
e.printStackTrace(); | |
Log.d("NoSuchAlgorithmException:", "===================================================="); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment