Android PDF从内部存储打开后立即关闭
我试图在从服务器下载pdf文件并将其存储在内部存储器中后访问它。问题在于成功下载文件后,它会在瞬间打开,然后立即关闭。有人能告诉我怎样做才合适吗。先谢谢你 以下是我下载pdf文件的代码: File File=新文件(getFilesDir(),“pdfFolder”)Android PDF从内部存储打开后立即关闭,android,android-studio,pdf,android-intent,Android,Android Studio,Pdf,Android Intent,我试图在从服务器下载pdf文件并将其存储在内部存储器中后访问它。问题在于成功下载文件后,它会在瞬间打开,然后立即关闭。有人能告诉我怎样做才合适吗。先谢谢你 以下是我下载pdf文件的代码: File File=新文件(getFilesDir(),“pdfFolder”) 如果(!file.isDirectory())file.mkdirs() File outputFile=新文件(文件, “samples.pdf”) //URLConnection…. //输入流… FileOutputStre
如果(!file.isDirectory())file.mkdirs()
File outputFile=新文件(文件, “samples.pdf”)
//URLConnection….
//输入流…
FileOutputStream FileOutputStream=新的FileOutputStream(outputFile) 以下是我查看pdf文件的代码: 文件pdfFile=新文件(getFilesDir(),“/pdfFolder/samples.pdf”)
Intent pdfIntent=新意图(Intent.ACTION\u视图)
pdfIntent.setDataAndType(Uri.fromFile(pdfFile),“application/pdf”); pdfIntent.setFlags(意图、标志、活动、清除、顶部)
星触觉 注意:绝对路径指向此“/data/user/0/com.package.name/pdfFolder/sample.pdf”尝试设置
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
而不是
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
这对我有用