Launch a local PDF file in Android 26
Hello Internet,
We have an app that is supposed to be able to open PDF files in their default viewer in either Desktop, Android or iOS.
It does this by copying the file from within File.applicationDirectory (or generating it internally) into File.applicationStorageDirectory, then taking the new path and making the appropriate call. In the case of Android, it would work so:
var request : URLRequest = new URLRequest(target.url);
//this is a workaround (bug introduce in new sdk)
//https://bugbase.adobe.com/index.cfm?event=bug&id=3759971
request.contentType = "text/plain";
navigateToURL(request);
and then delete the file when it was done. I don't know what bug the comment is referring to, the url is a 404.
Recently I've had to make a change for Android to use the new permission system. This works so:
- Apache Flex 4.16.1 FP30.0 AIR30.0
- <application xmlns="http://ns.adobe.com/air/application/30.0">
- <uses-sdk android:targetSdkVersion="23" android:minSdkVersion="23" />
And the app asks for permission before successfully launching the PDF file in its associated viewer.
Even more recently, Google Play requires targetSdkVersion="26", and now even once it has obtained permission, navigateToURL does nothing. I also tried StageWebView and got a blank screen on swv.loadURL(target.url), and target.openWithDefaultApplication() throws an exception saying it can't find the file (even though it's right there and target.exists = true). I can find the file through the file browser app, and launch it from there just fine.
Any ideas how I can fix this? Do I need to alter the url in some way?
target.url = file:///storage/emulated/0/PDFs/Doc_EA21E1DB-E8F1-D8BC-DC78-3CE973A98E3E.pdf
target.nativePath = /storage/emulated/0/PDFs/Doc_EA21E1DB-E8F1-D8BC-DC78-3CE973A98E3E.pdf
