【问题标题】:How can i change the permission of my apk to -rw -rw rw- , and install it?如何将我的 apk 的权限更改为 -rw -rw rw- 并安装它?
【发布时间】:2015-05-27 16:36:18
【问题描述】:

我正在将数据从服务器发送到我的平板电脑一个 apk 文件,我将使用它安装它,

Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

我有以下错误:错误解析,我想像这样 -rw -rw rw- 更改对我的 apk 文件的权限?。

【问题讨论】:

  • 看看这是否有帮助:stackoverflow.com/questions/8784404/…
  • error parse。这就是全部?您的代码看起来不错,但它不需要那个 FLAG_.... 为什么要更改文件权限?
  • 因为我是从 /data/data/com.so.and/app.apk 安装的,所以我遇到了 erreur prase 错误,所以 prasing 包有问题

标签: android installation apk file-permissions


【解决方案1】:
public class Chmod {
    public static void lancer() {

    String[] args2 = { "chmod", "604", "/data/data/com.so.and/sofiane.apk" };
    exec(args2);
}
    public static String exec(String[] args) {
        String result = "";
        ProcessBuilder processBuilder = new ProcessBuilder(args);
        Process process = null;
        InputStream errIs = null;
        InputStream inIs = null;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            int read = -1;
            process = processBuilder.start();
            errIs = process.getErrorStream();
            while ((read = errIs.read()) != -1) {
                baos.write(read);
            }
            baos.write('\n');
            inIs = process.getInputStream();
            while ((read = inIs.read()) != -1) {
                baos.write(read);
            }
            byte[] data = baos.toByteArray();
            result = new String(data);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (errIs != null) {
                    errIs.close();
                }
                if (inIs != null) {
                    inIs.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (process != null) {
                process.destroy();
            }
        }
        return result;
    }
}

【讨论】:

    猜你喜欢
    • 2014-11-16
    • 2013-03-14
    • 2018-04-05
    • 2018-12-01
    • 1970-01-01
    • 2021-05-13
    • 2020-09-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多