检索APK签名在运行时为Android [英] Retrieve the apk signature at runtime for Android

查看:132
本文介绍了检索APK签名在运行时为Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一些方法来检索有关的apk签名在运行时的信息?

Is there some way to retrieve information about the apk signature at runtime?

例如我有同样的应用程序有2个不同的签名签:APP-1.apk和app-2.apk,我希望能够区分这两种APK在运行时的。那可能吗?

For example I have the same App signed with 2 different signatures: app-1.apk and app-2.apk and I'd like to be able of differentiate both apk in run time. Is that possible?

我的目标是使用一个外部服务器,并根据应用程序和签名的版本code实行许可制度。

My goal is to implement a licensing system using a external server and based on the version code of the application and the signature.

推荐答案

您可以使用PackageManager访问的apk签名。  在包管理器中定义PackageInfo标志返回有关包中包含的签名信息。

You can access apk signature using PackageManager. PackageInfo flag defined in Package Manager return information about the signatures included in the package.

Signature[] sigs = context.getPackageManager().getPackageInfo(context.getPackageName(),PackageManager.GET_SIGNATURES).signatures;    
for (Signature sig : sigs)
{
    Log.i("App", "Signature : " + sig.hashCode());
}

http://developer.android.com/reference/android/内容/ PM / PackageManager.html

这篇关于检索APK签名在运行时为Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆