1 回答
TA贡献1862条经验 获得超6个赞
您可以从下面的代码创建哈希键
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)
}
}
你可以从应用的 build.gradle 文件中获取程序包名称,该应用程序 Id 是程序包名称。
将此哈希键和包名称添加到应用程序
添加回答
举报