【问题标题】:Android Open PDF IntentAndroid 打开 PDF 意图
【发布时间】:2014-09-03 15:30:43
【问题描述】:

我需要打开一个 PDF。我知道程序,这是我的代码:

string file_path = _path + url.Substring (5);
                if (System.IO.File.Exists(file_path)) {
                    Android.Net.Uri pdfFile = Android.Net.Uri.FromFile (new Java.IO.File (file_path));
                    Intent pdfIntent = new Intent (Intent.ActionView);
                    pdfIntent.SetDataAndType (pdfFile, "application/pdf");
                    pdfIntent.SetFlags (ActivityFlags.NoHistory);
                    _parent.StartActivity (pdfIntent);

                    return true;
                }

我正在使用 Xamarin,并且路径存在,因为我检查了它,如您所见。 该应用程序会打开 Adob​​e 阅读器,但在启动时会显示一条错误消息(未找到文件)。所以,我的文件在

/data/data/com.myapp/files/.hide/contents/file_test.pdf

有设置权限吗?我真的不明白为什么它无法打开我的文件!

【问题讨论】:

    标签: android pdf android-intent xamarin


    【解决方案1】:

    文件夹/data/data/com.myapp 是您的应用程序的私有文件夹。因此没有其他应用程序可以访问此文件夹的内容(在本例中为 Adob​​e 阅读器)。

    尝试将您的 pdf 文件放入 SDCard 文件夹中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-08
      • 1970-01-01
      • 2021-02-17
      • 2014-01-03
      • 2020-06-07
      • 1970-01-01
      • 2018-08-25
      • 1970-01-01
      相关资源
      最近更新 更多