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 issues. So, go-head by programmatically generation.
Steps to generate hash key:
- paste below coding in onCreate()
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.facebook.samples.hellofacebook",
PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
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).
0 comments:
Post a Comment