如何通过Android Intent使用外部应用程序打开3D-PDF文件

如何通过Android Intent使用外部应用程序打开3D-PDF文件,android,pdf,android-intent,Android,Pdf,Android Intent,我在Android应用程序中下载了一个3D-PDF文件,我想通过Intent在外部应用程序中打开它。我正在使用“3D PDF阅读器”作为外部应用程序 这是Java的源代码: Uri fileUri = FileProvider.getUriForFile(MainActivity.this, BuildConfig.APPLICATION_ID + ".provider", file); try {

我在Android应用程序中下载了一个3D-PDF文件,我想通过Intent在外部应用程序中打开它。我正在使用“3D PDF阅读器”作为外部应用程序

这是Java的源代码:

        Uri fileUri = FileProvider.getUriForFile(MainActivity.this,
                BuildConfig.APPLICATION_ID + ".provider", file);
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(fileUri, "application/pdf");
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            showMessage("Keine App zur Anzeige von PDF-Dokumenten gefunden!");
        }
错误消息是:“抱歉,无法从此PDF加载3D内容。该文档是安全的或不包含3D内容。”

我能够显示正常的PDF文件在一个外部应用程序与此代码。当我使用应用程序“Total Commander”(文件管理器应用程序)点击我的应用程序下载的3D-PDF时,我能够在外部应用程序(“3D PDF阅读器”)中加载3D-PDF文件。因此,实现我的目标一定是可能的


非常感谢您的帮助。

谢谢您的评论。我通读了你链接的文档。在我的代码中,我使用FileProvider向外部应用程序提供文件的临时权限。这适用于普通PDF文档,但不适用于3D PDF。我没有在FileProvider中指定文件的类型,所以我认为问题一定在别处。是否要查看与FileProvider相关的代码?请不要刻意尝试。标记\u活动\u否\u历史记录。
i能够显示普通PDF文件
是否与3D文件来自同一目录?错误消息后,查看器是否显示内容?它停止/结束了吗?请显示
file.getAbsolutePath()
的值。你在安卓10/11上吗?