try {
PackageManager manager = context.getPackageManager();
PackageInfo appInfo = manager.getPackageInfo(
YOUR_PACKAGE_NAME, PackageManager.GET_SIGNATURES);
// Now test if the first signature equals your debug key.
boolean shouldUseTestServer =
appInfo.signatures[0].toCharsString().equals(YOUR_DEBUG_KEY);
} catch (NameNotFoundException e) {
// Expected exception that occurs if the package is not present.
}
验证签名
本文提供了一段Java代码示例,用于从应用程序上下文中获取包管理器,并通过包名获取应用信息。随后,该代码会检查应用程序的第一个签名是否与预设的调试密钥相匹配。

被折叠的 条评论
为什么被折叠?



