有没有办法通过将应用程序复制到/ data / app来安装应用程序

时间:2011-04-27 15:04:54

标签: android install

要使用adb安装应用

adb push app.apk /data/app

然后安装应用程序。

但是当我只是将带有RootExplorer的文件复制到/ data / app时,它会复制,但不会安装。它就在那里。

有没有办法用终端仿真器安装应用程序?

1 个答案:

答案 0 :(得分:4)

实际上,安装应用的方式是:

adb install app.apk

如果您想以编程方式执行此操作,则必须使用Intent这样的内容:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/app.apk")),"application/vnd.android.package-archive");
startActivity(intent); 

在上面的例子中,apk位于SDCard目录中。