試試這個:
public void Get_hash_key() {
PackageInfo info;
try {
info = getPackageManager().getPackageInfo("your_package_name", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md;
md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String something = new String(Base64.encode(md.digest(), 0));
//String something = new String(Base64.encodeBytes(md.digest()));
Log.e("hash key", something);
}
} catch (PackageManager.NameNotFoundException e1) {
Log.e("name not found", e1.toString());
} catch (NoSuchAlgorithmException e) {
Log.e("no such an algorithm", e.toString());
} catch (Exception e) {
Log.e("exception", e.toString());
}
}
添加你的包名和onCreate
調用此函數()你Mainactivity的
將打印在logcat的哈希鍵...
副本粘貼開發商面板上的按鍵,刪除其他鍵
調試密鑰生成?或釋放 – rafsanahmad007
生成的調試密鑰 – cincin
你是如何獲得散列密鑰的? – rafsanahmad007