peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
09/26/13 01:19 PM (10 years ago)

Android 3.0: PDF error document path is not valid

When I select to "Open Document" from the PDF screen in my app (after downloading it), it asks what app I want to use to view it. I have 3 apps, and they all declare an issue opening the PDF. The Adobe Reader app says "document path is not valid", and the other apps say things such as "document may be corrupt or not exist". The PDF definitely exists - I can view it on the iOS version of this app, and via a web browser. The document appears to download fine within the app. I've inspected the code in BT_screen_pdfDoc.java, and I feel like it makes sense to me - downloads to cache using the dataURL and saves with the saveAsFilename, then opens in the cache, passing the saveAsFileName and setting the Mime Type as application/pdf. Makes sense to me. LogCat does not show any errors, which makes me think the app thinks that it's doing its job. I've tried a couple of other links, and they all result in the "document path is not valid error". The bottom line is, I can't view PDFs in the emulator, or the test Motorola Droid I have. It doesn't seem like the app's fault, but I can't guess what else it might be.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
09/26/13 04:01 PM (10 years ago)
Are you using a dataURL for the Android project? It works in iOS but not Android? If the logcat is not showing an error, and you're certain the dataURL link is valid, I wonder if the 'launch app' (the app used to actually open and view the PDF) is finding the document...? In the logcat, try removing the 'filter' for only Buzztouch and see if you can wade through the logs to see what the other android activities are saying... Cheers! -- Smug
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
09/27/13 05:07 AM (10 years ago)
Thanks for the suggestion Smug. I appear to get two errors: one when the "document not found" window appears, and another when I tap OK to make it go away. The first error is "Uncaught exception thrown by finalizer" "java.lang.NullPointerException" The second error is something about a "leaked window": "Activity com.adobe.reader.ARViewer has leaked window com.android.internal.polict.impl.PhoneWindow$DecorView@413a8c88 that was originally added here" The app doesn't crash - I can tap OK on the error that appears in Adobe Reader, and I'm returned to the app.
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
09/27/13 11:54 AM (10 years ago)
Ok, I'm pretty sure now that the issue is with the NullPointerException. I just don't know what to do about it :) The parts of the LogCat I think are relevant are below. I tap on "download" in the app, and then I tap "open document": 09-27 14:36:58.761: W/InputManagerService(3282): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@414d50a8 09-27 14:36:59.901: W/ZZ(4248): BT_screen_pdfDoc:downloading binary data from http://w3.securitytechnologies.com/irstdocs/datasheet/104869.pdf Saving As: 104869.pdf 09-27 14:36:59.901: W/ZZ(4248): BT_downloader:downloadBinaryData from URL: http://w3.securitytechnologies.com/irstdocs/datasheet/104869.pdf 09-27 14:36:59.901: W/ZZ(4248): BT_downloader:downloadBinaryData Save As File Name:: 104869.pdf ...…. 09-27 14:37:23.941: I/ActivityManager(3282): START {act=android.intent.action.VIEW dat=file:///data/data/com.myapp/files/104869.pdf typ=application/pdf flg=0x7000000 cmp=com.adobe.reader/.AdobeReader} from pid 4248 09-27 14:37:23.992: W/NetworkManagementSocketTagger(3282): setKernelCountSet(10041, 1) failed with errno -2 09-27 14:37:24.162: I/ActivityManager(3282): START {cmp=com.adobe.reader/.ARViewer (has extras)} from pid 3804 09-27 14:37:24.252: I/WindowManager(3282): createSurface Window{415de728 Starting com.adobe.reader paused=false}: DRAW NOW PENDING 09-27 14:37:24.412: V/PhoneStatusBar(3336): setLightsOn(true) 09-27 14:37:25.222: D/dalvikvm(3804): GC_EXPLICIT freed 329K, 5% free 10720K/11207K, paused 5ms+12ms 09-27 14:37:25.242: E/System(3804): Uncaught exception thrown by finalizer 09-27 14:37:25.242: E/System(3804): java.lang.NullPointerException 09-27 14:37:25.242: E/System(3804): at com.omniture.AppMeasurementBaseSE13.finalize(AppMeasurementBaseSE13.java:43) 09-27 14:37:25.242: E/System(3804): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:182) 09-27 14:37:25.242: E/System(3804): at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168) 09-27 14:37:25.242: E/System(3804): at java.lang.Thread.run(Thread.java:856) 09-27 14:37:25.286: W/Settings(3804): Setting android_id has moved from android.provider.Settings.System to android.provider.Settings.Secure, returning read-only value. It looks to me like the document is downloaded and saved properly in the cache, so I'm not sure why the Adobe Reader app isn't picking it up.
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
09/30/13 10:42 AM (10 years ago)
I was able to get a developer friend to take a look and see what he could find. He found that in BT_downloader.java when the output is created, Context.MODE_PRIVATE is used, which means that only the app can open the file. I changed it to Context.MODE_WORLD_READABLE, which allows a PDF reading app to load the file in read-only mode.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
09/30/13 05:29 PM (10 years ago)
Glad you got that worked out; I would have never thought of that kind of detail. Where did you make the changes at? Cheers! -- Smug
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
10/01/13 05:56 AM (10 years ago)
Thanks! The change is around line 227 in BT_downloader.java, within the "download binary data from URL" code.
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/03/13 08:46 PM (10 years ago)
Revisiting (& hijacking) this post! I followed the Context.MODE_WORLD_READABLE directions. I also figured out rather quickly to store PDF documents in the "SDCard" of the emulator. Here's my question! I'm able to open Adobe Reader and access the PDF from there. However, when I access my app, click on a PDF, and then choose "Open Document", I receive "Error: The document path is not valid" Is this normal behavior within the emulator? Thanks!! -Nicholas
 
ictguy
Aspiring developer
Profile
Posts: 564
Reg: Jun 17, 2011
Mildura, Austra...
15,840
like
10/03/13 09:42 PM (10 years ago)
Hey great find! I just ran into this problem too. I don't think I would have ever solved the issue unless I saw this thread :) This works great for the PDF as a URL, however it still doesn't work for local PDF files (same issue as Nicholas above). Anyone gotten it to work locally? Anyway, Thanks again for sharing. Cheers Darrel
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/04/13 01:13 PM (10 years ago)
Would this issue have anything to do with Content Providers/Content Resolvers? http://developer.android.com/guide/topics/providers/content-providers.html -Nicholas
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.