To Generate Facebook Hashkey from app package

by Tuesday, August 12, 2014 0 comments
To Generate Facebook Hash key by using two steps.

  • via command prompt (already discussed in previous POST)
  • via coding
By generate hash key using command prompt will work first time only after that it will not works and also got the same issuesSo, go-head by programmatically generation.

Steps to generate hash key:
  • paste below coding in onCreate()
 try {  
      PackageInfo info = getPackageManager().getPackageInfo(  
      for (Signature signature : info.signatures) {  
           MessageDigest md = MessageDigest.getInstance("SHA");  
           Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));  
 } catch (NameNotFoundException e) {  
 } catch (NoSuchAlgorithmException e) {  

Change "com.facebook.samples.hellofacebook" with your package name in the above coding without fail(You may found your package name in Android Manifest file).

karthik nagarajan


Welcome to Android-Action Blog. I’m a normal guy, who is passionate about Mobile Coding. Here I am writing about Android. Happy learning


Post a Comment