我正在使用
以编程方式从我的 SD 卡安装 .apkString fileName = Environment.getExternalStorageDirectory() + "/myApp.apk";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
startActivity(intent);
这确实可以解决安装问题,但我得到了一个完整的操作窗口,其中显示了两个选项,包括软件包安装程序,因此您单击软件包安装程序选项,然后它会将您带到安装窗口。但我想要的是摆脱这个完整操作窗口,直接进入安装窗口。有办法吗?
最佳答案
好的,我知道了,我需要删除
<category android:name="android.intent.category.DEFAULT" />
来自:
`
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:scheme="file" />
<data android:mimeType="application/vnd.android.package-archive" />
</intent-filter>`
关于Android:以编程方式安装应用程序时使用窗口完成操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5815639/