我的代码应该安装我的应用程序,名为“xadb-build.apk”,但它什么都不做,没有错误,没有强制关闭,我只看到授予烤面包的超级用户权限。这里是我的方法如何从SD卡安装应用程序?
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答案中的一条评论建议? –
'getExternalStorageDirectory();'。这不是SD卡,而是外部存储器。你在说什么? – greenapps