【发布时间】:2016-12-26 02:35:43
【问题描述】:
我的代码应该安装我的名为“xadb-build.apk”的应用程序,但它什么也没做,没有错误,没有强制关闭,我只看到授予 toast 的超级用户权限。这是我的方法
File sdCard = Environment.getExternalStorageDirectory();
String fileStr = sdCard.getAbsolutePath() + "/download";// +
// "app-release.apk";
File file = new File(fileStr, "xadb-build.apk");
if (file.exists()) {
try {
String command;
command = "adb install -r " + file;
Process proc = Runtime.getRuntime().exec(
new String[] { "su", "-c", command });
proc.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
}
我从here 得到这个代码(见 palak 的回答)
【问题讨论】:
-
您是否尝试过使用
pm install而不是adb install作为 palak 回答的 cmets 之一? -
getExternalStorageDirectory();。那不是SD卡,而是外部存储器。你在说什么?