我正在以编程方式安装 Android 应用程序。出现一个对话框“Complete Action Using”。 “Package Installer”之间有许多选项可用。如何在不要求用户选择的情况下隐式选择“Package Installer”?
编辑 我使用的代码是:
Intent intent = new Intent();
intent .setDataAndType(Uri.fromFile(new File("/mnt/sdcard/download/App.apk")),"application/vnd.android.package-archive");
startActivity(intent);
最佳答案
我正在使用此代码来完成该任务。我猜你错过了添加类型?
Uri fileUri = Uri.fromFile(myFile);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(fileUri, "application/vnd.android.package-archive");
startActivity(intent);
关于java - android:使用包安装程序以编程方式安装应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11137439/