Opening Pdf With Other App From Assets Folder, Workarounds
Solution 1:
Therefore I need to copy the files to the external storage and provide that file to the intent.
You can also try my StreamProvider
, a canned ContentProvider
, based on Google's FileProvider
, that streams from assets.
For multiple assets, this should work for the StreamProvider
XML metadata:
<?xml version="1.0" encoding="utf-8"?><pathsxmlns:android="http://schemas.android.com/apk/res/android"><assetname="whatevs"/></paths>
That should resolve all content://your.authority.name.goes.here/whatevs/*
Uri
values (for various values of *
) to files inside of assets/
. If you want to limit the scope to some specific subdirectory of assets/
(say, assets/goodstuff/
), you would use:
<?xml version="1.0" encoding="utf-8"?><pathsxmlns:android="http://schemas.android.com/apk/res/android"><assetname="whatevs"path="goodstuff/"/></paths>
And, if this does not work, it should, so feel free to file an issue with a reproducible test case.
Is this a good work-around or will this cause problems with the pdf-viewing app?
startActivity()
is asynchronous, and so the external PDF viewer will never be able to access the file this way.
Post a Comment for "Opening Pdf With Other App From Assets Folder, Workarounds"