无法解析方法'toByteArray()'

时间:2015-09-08 09:45:22

标签: android-fragments

try {
    PackageInfo info = getPackageManager().getPackageInfo("com.example.ak.locationsviewer", PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.**toByteArray()**);
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
    }
} catch (PackageManager.NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}

1 个答案:

答案 0 :(得分:2)

您似乎使用了错误的类。

您应该使用android.content.pm.Signature代替java.security.Signature