Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
277 views
in Technique[技术] by (71.8m points)

android - Best way to include pdfs in an app

I have to develop an app which is basically a pdf reader: it is composed by a list, each list element is a pdf file name, when user clicks on a list element the pdf is popped out, read by a pdf reader installed on the device.

Now, problem is that i'd like to include these pdfs in my app. Till now the only way I found is to set them as resource, but the problem is that each time I want to display one of them I'll have to copy it in a public folder and this obviously takes time...isn't there another way?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can add a ContentProvider to your app that streams the PDFs to the other process from the resource. For example, my StreamProvider extends Android's FileProvider to add support for serving files from raw resources or assets. The demo project, in particular, demonstrates serving a PDF from assets.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...