android 静默安装的问题!!!!!!!!!

llller 2011-11-18 12:51:22
String[] args = { "pm", "install", "-r", apkAbsolutePath };
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;

这段代码要放在哪里执行????

上面的代码来自:http://blog.csdn.net/sodino/article/details/6238818
...全文
291 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
lizhengjun2010 2011-11-18
  • 打赏
  • 举报
回复
http://blog.csdn.net/sodino/article/details/6238818
这两种方法都可以实现,但都不能实现通用性

1.内置到ROM。即APK包的安装位置是/system/app下。
这方法需要手机root,没有root手机行不通

2.使用APK的目标安装系统同样的签名。
这方法需要目标系统相同的签名,系统不同签名不同 ,不通用

要真正实现静默安装,还是得直接使用底层未提供的接口,eclipse不能编译,但源码中
mmm命令能编译生成apk,可以完美实现静默安装。

80,348

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧