有没有办法通过编程方式从com.android.filemanager安装apk

有没有办法通过编程方式从com.android.filemanager安装apk,android,Android,使用“adb install xx.apk”将获得一个弹出窗口,要求oppo和vivo提供生产密码,但是如果将apk文件推送到/SD卡,然后转到filemangeer并点击刚刚推送的apk,则无需密码。 我想知道是否有办法通过另一个apk实现这一点 String sdcardRoot = Environment.getExternalStorageDirectory().getAbsolutePath(); final String apkSave

使用“adb install xx.apk”将获得一个弹出窗口,要求oppo和vivo提供生产密码,但是如果将apk文件推送到/SD卡,然后转到filemangeer并点击刚刚推送的apk,则无需密码。 我想知道是否有办法通过另一个apk实现这一点

            String sdcardRoot = Environment.getExternalStorageDirectory().getAbsolutePath();
            final String apkSavePath = sdcardRoot + "/510.apk";
            File apkFile = new File(apkSavePath);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            if (!apkFile.exists()) {
                return;
            }

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                try {
                    String ss = "com.xunmeng.pinduoduo" + ".provider";
                    Uri contentUri = FileProvider.getUriForFile(getApplicationContext(), ss, apkFile);
                    intent.setAction(Intent.ACTION_VIEW);
                    intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            }
            try {
                startActivity(intent);
            } catch (Exception e) {
                e.printStackTrace();

            }
这一个不起作用,因为它从apk I build调用了文件安装,而不是com.android.filemanger。
有没有办法从com.android.filemanger运行文件安装?

有两种方法可以达到您的目的:1。通过在设置中启用“安装未知源应用程序”,使您的应用程序能够安装apks。2.将意图发送到文件管理器。@cowboi peng I替换intent.setAction(intent.ACTION\u视图);使用intent.setAction(“com.android.filemanager/com.android.filemanager.filemanagerlistativity”);然后获取以下错误:android.content.ActivityNotFoundException:未找到用于处理意图的活动{act=com.android.filemanager/com.android.filemanager.filemanagerlistativity dat=content://com.xunmeng.pinduoduo.provider/external_storage_root/510.apk typ=application/vnd.android.package-archive flg=0x10000001}添加以下内容:intent.setPackage(“com.android.filemanager”);intent.setAction(intent.ACTION\u安装\u包);然后出现错误:android.content.ActivityNotFoundException:找不到处理Intent的活动{act=android.Intent.action.INSTALL_PACKAGE dat=con