android - 在根设备android中安装apk后启动应用程序
问题描述
嗨,我想从 sd 卡安装 apk 到 root android 设备,我安装成功 apk 但安装后没有打开应用程序,它在 android 中显示板菜单,安装后如何启动应用程序
String path = "/sdcard/Android/data/com.apk.applicaiton/files/ApkFile/test.apk";
public static Boolean InstallApk(String path)
{
File file = new File(path);
if(file.exists()){
try {
Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","pm install -r -d " + path});
proc.waitFor();
BufferedReader input = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
String line;
Boolean hasError = false;
while ((line = input.readLine()) != null) {
if(line.contains("Failure")){
hasError = true;
}
}
if(proc.exitValue() != 0 || hasError){
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}else{
Timber.i("Path is not found:%s", path);
}
return false;
}
解决方案
推荐阅读
- ios - 无法将“UITableViewCell”类型的值转换为“SwipeCellKit.SwipeTableViewCell”
- ansible - Ansible 在使用暂停时将垃圾放入变量中
- react-native - 向上滚动时如何使标题消失,向下滚动时如何使标题可见?
- yii2 - 如何在yii2 gridview数据行中获取上一行和下一行模型ID
- python - 对嵌套字典中的特定元素求和
- python - python 3的scitools是否存在?
- excel - 使用 VBA 读取文本行的特定部分
- python-3.x - Tkinter 按钮在切换窗口时失去回调(类实现)(python 3.X)
- ruby-on-rails - Rails 嵌套表单未插入数据库(oracle)
- python - AttributeError:“unicode”对象没有属性 XXX