In our application we are storing few pdf files inside asstes folder(<1MB).
Using Intent we want to open that pdf. Is it possible ? If yes, how to do
that ?
What we tried :
If we copy file from assets to sd card and then try to open using intent it
is working.
But we directly want to open it from assets folder.
On Tue, Oct 30, 2012 at 8:01 AM, Jovish P <android.f...@gmail.com> wrote:
> In our application we are storing few pdf files inside asstes folder(<1MB).
> Using Intent we want to open that pdf. Is it possible ? If yes, how to do
> that ?
It's hard to help if you don't provide enough information about your problem.
> What we tried :
> If we copy file from assets to sd card and then try to open using intent it
> is working.
What are you using to "open" the PDF files? Do you mean "view/display"
or "read the file". Android does not support PDF natively so I suppose
that you use either an external application or a PDF rendering
library.
> But we directly want to open it from assets folder.
Doesn't <some-context-instance>.getAssets().open(assetName) work for you?
-- "The flames are all long gone, but the pain lingers on"
> > If we copy file from assets to sd card and then try to open using intent
> it
> > is working.
> What are you using to "open" the PDF files? Do you mean "view/display"
> or "read the file". Android does not support PDF natively so I suppose
> that you use either an external application or a PDF rendering
> library.
> > But we directly want to open it from assets folder.
> Doesn't <some-context-instance>.getAssets().open(assetName) work for you?
As you said, reading PDFs is not a native feature and requires an external
app, which would not have permission to read the PDF from another app's
Assets folder.
I believe the OP would have to write his own PDF viewer imbedded in his
app, or stick with the "copy to SDcard then open" strategy.
--------------------------------------------------------------------------- ----------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices
When user clicks on a button i want to open the pdf file stored inside our
application(ie which is inside Assets folder of our app). Open means , to
view the pdf file using Intent. I don't have any problem in using third
party applications to view pdf file.In the intent i sepcify mimetype , so
it will list all the pdf viewer installed in his phone. So user can select
his favorite pdf viewer to view the pdf file which is stored in our
application
<some-context-instance>.getAssets().open(assetName) will return
inputstream. That is not wht we need. Thanks for this suggestion
I guess now everything is clear. sorry for my bad English.
On Wed, Oct 31, 2012 at 6:51 AM, TreKing <treking...@gmail.com> wrote:
> On Tue, Oct 30, 2012 at 6:47 PM, Carlos A. M. dos Santos <
> unixma...@gmail.com> wrote:
>> > What we tried :
>> > If we copy file from assets to sd card and then try to open using
>> intent it
>> > is working.
>> What are you using to "open" the PDF files? Do you mean "view/display"
>> or "read the file". Android does not support PDF natively so I suppose
>> that you use either an external application or a PDF rendering
>> library.
>> > But we directly want to open it from assets folder.
>> Doesn't <some-context-instance>.getAssets().open(assetName) work for you?
> As you said, reading PDFs is not a native feature and requires an external
> app, which would not have permission to read the PDF from another app's
> Assets folder.
> I believe the OP would have to write his own PDF viewer imbedded in his
> app, or stick with the "copy to SDcard then open" strategy.
> --------------------------------------------------------------------------- ----------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
On Wed, Oct 31, 2012 at 2:21 AM, TreKing <treking...@gmail.com> wrote:
> As you said, reading PDFs is not a native feature and requires an external
> app, which would not have permission to read the PDF from another app's
> Assets folder.
FYI apparently you don't need any permissions to access another app's
assets. I was surprised too, but see here:
On Wed, Oct 31, 2012 at 5:00 AM, Latimerius <l4t1m3r...@gmail.com> wrote:
> FYI apparently you don't need any permissions to access another app's
> assets. I was surprised too, but see here:
On Wed, Oct 31, 2012 at 3:09 AM, Jovish P <android.f...@gmail.com> wrote:
> When user clicks on a button i want to open the pdf file stored inside our
> application(ie which is inside Assets folder of our app). Open means , to
> view the pdf file using Intent. I don't have any problem in using third
> party applications to view pdf file.In the intent i sepcify mimetype , so
> it will list all the pdf viewer installed in his phone. So user can select
> his favorite pdf viewer to view the pdf file which is stored in our
> application
> <some-context-instance>.getAssets().open(assetName) will return inputstream.
> That is not wht we need. Thanks for this suggestion
I see. So I suggest you to create a content provider and invoke the
third-party app with a corresponding intent (supposing that the viewer
is able to read from a provider, of course). That would be the elegant
and fancy approach.
A not-so-fancy solution is to copy the PDF to the SD card and invoke
the viewer app with a file:// URI. This approach has a disadvantage:
it's hard to know when the copy can be removed because you don't know
when the viewer will stop accessing it.
> I guess now everything is clear. sorry for my bad English.
-- "The flames are all long gone, but the pain lingers on"
} } On Thursday, November 1, 2012 7:05:55 AM UTC-5, casantos wrote:
> On Wed, Oct 31, 2012 at 3:09 AM, Jovish P <androi...@gmail.com<javascript:>> > wrote: > > When user clicks on a button i want to open the pdf file stored inside > our > > application(ie which is inside Assets folder of our app). Open means , > to > > view the pdf file using Intent. I don't have any problem in using third > > party applications to view pdf file.In the intent i sepcify mimetype , > so > > it will list all the pdf viewer installed in his phone. So user can > select > > his favorite pdf viewer to view the pdf file which is stored in our > > application
> > <some-context-instance>.getAssets().open(assetName) will return > inputstream. > > That is not wht we need. Thanks for this suggestion
> I see. So I suggest you to create a content provider and invoke the > third-party app with a corresponding intent (supposing that the viewer > is able to read from a provider, of course). That would be the elegant > and fancy approach.
> A not-so-fancy solution is to copy the PDF to the SD card and invoke > the viewer app with a file:// URI. This approach has a disadvantage: > it's hard to know when the copy can be removed because you don't know > when the viewer will stop accessing it.
> > I guess now everything is clear. sorry for my bad English.
> -- > "The flames are all long gone, but the pain lingers on"