Android 静默安装 总结备忘
来源:互联网 发布:mac口红日本官网 编辑:程序博客网 时间:2024/04/30 06:26
先将asset下的apk拷贝到sd卡下 在执行下列代码
cmd = “pm install -r X.apk”
public static int execRootCmdSilent(String cmd) {
int result = -1;
DataOutputStream dos = null;
Process p = null;
cmd = “pm install -r X.apk”
public static int execRootCmdSilent(String cmd) {
int result = -1;
DataOutputStream dos = null;
Process p = null;
try {
p = Runtime.getRuntime().exec("su");
dos = new DataOutputStream(p.getOutputStream());
p = Runtime.getRuntime().exec("su");
dos = new DataOutputStream(p.getOutputStream());
Log.i(TAG, cmd);
dos.writeBytes(cmd + "\n");
// dos.flush();
dos.writeBytes("exit\n");
dos.flush();
p.waitFor();
result = p.exitValue();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (dos != null) {
try {
dos.close();
dos = null;
} catch (IOException e) {
e.printStackTrace();
}
}
if (p != null) {
p.destroy();
p = null;
}
}
return result;
}
dos.writeBytes(cmd + "\n");
// dos.flush();
dos.writeBytes("exit\n");
dos.flush();
p.waitFor();
result = p.exitValue();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (dos != null) {
try {
dos.close();
dos = null;
} catch (IOException e) {
e.printStackTrace();
}
}
if (p != null) {
p.destroy();
p = null;
}
}
return result;
}
0 0
- Android 静默安装 总结备忘
- Android 静默升级,静默安装
- android静默安装探讨
- Android静默安装
- Android静默安装
- Android 实现静默安装
- android静默安装
- android 静默安装
- android 静默安装
- android 静默安装
- Android静默安装
- android 静默安装
- Android静默安装
- Android静默安装
- android 静默安装apk
- Android静默安装
- android静默安装探讨
- android --静默安装
- louboutin this thing can do. Support and support for foreign developers to Chinese developers are t
- hollister france pas cher co-service passengerYesterday
- 英文网页最常碰到的词汇术语
- hogan uomo the discovery has been canceled. Metro staff told him that the one-way ticket back are p
- C#输出一条或多条数据,表扩展,函数调用
- Android 静默安装 总结备忘
- abercrombie fitch 2011
- PRML 1 INTRODUCTION
- Xcode 5 单元测试(二)OCMock和GHUnit
- 第十周项目4-大奖赛计分1
- WEB安全性测试考虑的几个方面
- [Nginx]配置优化详解
- 学习笔记-实验楼项目课(Linux桌面字典)
- Linux相关问题-CentOS6.5 x64版本下Tomcat无法自启动的解决办法