如何获得应用程序的签名? [英] How to get app signature?
问题描述
有什么办法如何从APK检索应用程序签名?我用我的钥匙从密钥库签署,是有办法,如何编程找回?
Is there any way how to retrieve app signature from APK? I signed it with my key from keystore and is there way, how to retrieve it programatically?
推荐答案
您可以访问APK的签名签署这样的使用PackageManager类 <一href="http://developer.android.com/reference/android/content/pm/PackageManager.html">http://developer.android.com/reference/android/content/pm/PackageManager.html
You can access the APK's signing signature like this using the PackageManager class http://developer.android.com/reference/android/content/pm/PackageManager.html
Signature[] sigs = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES).signatures;
for (Signature sig : sigs)
{
Trace.i("MyApp", "Signature hashcode : " + sig.hashCode());
}
我用这个用散列code为我调试键进行比较,以此来确定APK是否是调试APK或释放APK。
I've used this to compare with the hashcode for my debug key, as a way to identify whether the APK is a debug APK or a release APK.
这篇关于如何获得应用程序的签名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!