【发布时间】:2020-11-24 11:06:05
【问题描述】:
我尝试使用媒体存储来存储来自专用网络的 pdf 下载(在 Environment.DIRECTORY_DOWNLOADS 中)并显示它。我希望用户能够选择应用程序来显示它。 在我的代码中,我很难定义文件路径“dataFile” 可以给点建议吗,谢谢 洛朗
String fileType="application/pdf";
String filetxt="Choose pdf Application";
final Intent intent = new Intent(Intent.ACTION_VIEW)
.setDataAndType(dataFile, fileType);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Intent intentChooser = Intent.createChooser(intent,filetxt);
context.startActivity(intentChooser);
【问题讨论】:
-
先说说你是怎么下载文件的。您将使用或拥有一个 uri。使用那个。使用媒体存储 uri。
-
try to use media store to store a pdf download在使用 ACTION_VIEW 之前,请务必先解决这个问题。说出你已经拥有的东西。
标签: android download mediastore