【问题标题】:Android assets folder pdf path [duplicate]Android资产文件夹pdf路径[重复]
【发布时间】:2013-11-28 10:23:55
【问题描述】:

我的资产文件夹:

Intent intent = new Intent(this, MyPdfViewerActivity.class); intent.putExtra(MyPdfViewerActivity.EXTRA_PDFFILENAME, "PDF FILE PATH"); startActivity(intent);

如何获取路径?

【问题讨论】:

    标签: android file pdf path assets


    【解决方案1】:

    尝试使用:

    Intent intent = new Intent(this, MyPdfViewerActivity.class); intent.putExtra(MyPdfViewerActivity.EXTRA_PDFFILENAME, "file:///android_asset/xy.pdf"); startActivity(intent);
    

    【讨论】:

      【解决方案2】:

      试试这个

       Uri path = Uri.parse("file:///android_asset/about.pdf");
       Intent intent  = new Intent(Intent.ACTION_VIEW);
       intent.setDataAndType(path, "application/pdf");
       intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
       startActivity(intent);
      

      【讨论】:

      • 我使用了你的代码,但是它提示'invalid file path',为什么?
      • 这是无效的,因为在 apk 到达设备时资产还不是文件。
      猜你喜欢
      • 2023-03-31
      • 2012-11-02
      • 2011-06-14
      • 2014-05-19
      • 2011-06-29
      • 2018-01-19
      • 2017-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多