While developing for the Android Application we may need to generate our System KeyHash. Sometimes it may be difficult or wrong if we miss any of the precise instruction. So code below will show your system KeyHash in LogCat View:

try {
     PackageInfo info = getPackageManager().getPackageInfo("your.package.name",PackageManager.GET_SIGNATURES);

     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) {


Save your changes and re-run your application. Check your LogCat output for a message similar to this:

12-20 10:47:37.747: D/KeyHash:(936): gpjJPSisErdsl65a1wOqJ+Bpw14=

The bold text above is the KeyHas you needed. 

FYI: I have used above code to get the KeyHash for Facebook integration in Android. So I am quiet not sure about other usage, but still you gotta try 😛

Enjoy 😉