Retrieve the apk signature at runtime for Android

前端 未结 2 1092
醉梦人生
醉梦人生 2020-12-06 11:40

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

For example I have the same App signed with 2 different signatures: app-1.apk and app-

2条回答
  •  孤街浪徒
    2020-12-06 12:07

    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/content/pm/PackageManager.html

提交回复
热议问题