我正在尝试在Android应用程序中将内容共享给Facebook,并且我需要密钥哈希...但由于不赞成使用GET_SIGNATURES,所以我无法在logcat上查看HashKey ...是否有任何方法可以查看我的哈希键... 这是代码 公共类MainActivity扩展了AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
printhashkey();
}
public void printhashkey(){
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.capstone.facebookshare",
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 (PackageManager.NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
}
}