【问题标题】:accessing APK contents from the code on android device从 android 设备上的代码访问 APK 内容
【发布时间】:2011-10-05 18:09:58
【问题描述】:

我需要从设备上运行的同一应用程序的代码访问我的应用程序 APK 的内容。 我编写的这段代码运行良好,并在我的 2.2 和 2.3.3 设备上返回数据。

但这是一种合法的方式吗?它是否适用于从 2.1 到任何未来或现有版本的所有版本?

主要原因是检测apk原始签名或重新打包的apk。

这是我访问 META-INF/CERT.RSA 的代码:

    String path = this.getApplication().getPackageCodePath();
    try
    {
        ZipFile zfile = new ZipFile(path);
        ZipEntry zentry = zfile.getEntry("META-INF/CERT.RSA");
        long siz = zentry.getSize();

        byte[] buf=new byte[(int) siz];
        InputStream istream = zfile.getInputStream(zentry);

        int ret = istream.read(buf);
        istream.close();

    }
    catch (IOException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

提前谢谢你

【问题讨论】:

    标签: android apk


    【解决方案1】:

    是的,这会起作用。

    目前它适用于最新的 Android 3.2,并且没有任何方法被标记为已弃用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-22
      • 1970-01-01
      • 2015-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-05
      相关资源
      最近更新 更多