摘要:Android - Keyhash
因為Facebook需要KeyHash,
但用下指令的方式,或許有點麻煩。
有一段程式碼,可以直接顯示 KeyHash ,如下
// Get keyhash for application.
try {
PackageInfo info = getPackageManager().getPackageInfo(YOUR_PACKAGE_NAME, PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
// Log.i(TAG, "KeyHash: " + Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}