1 回答

TA貢獻1862條經(jīng)驗 獲得超6個贊
您可以從下面的代碼創(chuàng)建哈希鍵
fun getPackageHash() {
try {
@SuppressLint("PackageManagerGetSignatures")
val info = context.packageManager.getPackageInfo(
"your package name",//give your package name here
PackageManager.GET_SIGNATURES)
for (signature: Signature in info.signatures) {
val md = MessageDigest.getInstance("SHA")
md.update(signature.toByteArray())
Log.d("LinkedInSignInManager", "Hash : " + Base64.encodeToString(md.digest(), Base64.NO_WRAP))//Key hash is printing in Log
}
} catch (e: PackageManager.NameNotFoundException) {
Log.d("LinkedInSignInManager", e.message, e)
} catch (e: NoSuchAlgorithmException) {
Log.d("LinkedInSignInManager", e.message, e)
}
}
你可以從應(yīng)用的 build.gradle 文件中獲取程序包名稱,該應(yīng)用程序 Id 是程序包名稱。
將此哈希鍵和包名稱添加到應(yīng)用程序
添加回答
舉報