GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
10/04/13 06:28 PM (12 years ago)

One more plea - Local PDF files

Hello everybody! My first Android app (revisited from my first iOS app a year ago) is on the cusp of submission to Google Play. However, there's a "major" issue I have to overcome before it can even be presented. Currently, and it sounds like many may have experience this problem, locally saved PDF files cannot be read on an Android emulator/Android device. The error I receive is: "The document path is not valid" PDF files accessed via URL work like a charm, but I want the PDFs to be accessed locally. The .apk package contains the PDF files and what not - the problem from what I can tell is that third party PDF readers do not have permission to access the PDF files within my app. I don't know how to correct this... something tells me it might have to do with Content Providers and Content Resolvers, but I could be completely wrong. See: http://developer.android.com/guide/topics/providers/content-providers.html Any insight on the matter? Any code I could plug in?! Thank you so much! -Nicholas
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
10/04/13 10:17 PM (12 years ago)
No more insights, but they certainly need to work offline. I know I have the working offline, but in older apps.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/04/13 10:47 PM (12 years ago)
Have you shared any LogCat output previously on this that I might have missed? A snippet at the time you try to access the file would be helpful. Mark
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/04/13 10:49 PM (12 years ago)
Will get on that now! T-minus 5 minutes for LogCat! -Nicholas
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/04/13 10:53 PM (12 years ago)
This is what the LogCat spits out as soon as I choose "Adobe Reader" after clicking "Open Document": 10-05 01:51:04.257: I/ActivityManager(307): START {act=android.intent.action.VIEW dat=file:///data/data/com.tgfugamespe/files/21 (K-6).pdf typ=application/pdf flg=0x7000000 cmp=com.adobe.reader/.AdobeReader u=0} from pid 1128 10-05 01:51:04.265: W/audio_hw_primary(109): out_write() limiting sleep time 116462 to 39909 10-05 01:51:04.281: E/SocketStream(106): readFully was waiting for 459888 bytes, got 49152 10-05 01:51:04.281: E/SocketStream(106): readFully was waiting for 410736 bytes, got 49152 10-05 01:51:04.281: E/SocketStream(106): readFully was waiting for 361584 bytes, got 49152 10-05 01:51:04.281: E/SocketStream(106): readFully was waiting for 312432 bytes, got 16384 10-05 01:51:04.281: E/SocketStream(106): readFully was waiting for 296048 bytes, got 245760 10-05 01:51:04.281: E/SocketStream(106): readFully was waiting for 50288 bytes, got 49152 10-05 01:51:04.289: D/dalvikvm(307): GC_FOR_ALLOC freed 299K, 17% free 11326K/13511K, paused 7ms, total 7ms 10-05 01:51:04.289: I/ActivityManager(307): Start proc com.adobe.reader for activity com.adobe.reader/.AdobeReader: pid=1196 uid=10060 gids={3003, 1015, 1028} 10-05 01:51:04.293: I/dalvikvm(1196): Turning on JNI app bug workarounds for target SDK version 8... 10-05 01:51:04.297: E/Trace(1196): error opening trace file: No such file or directory (2) 10-05 01:51:04.305: W/audio_hw_primary(109): out_write() limiting sleep time 89977 to 39909 10-05 01:51:04.329: D/dalvikvm(1196): WAIT_FOR_CONCURRENT_GC blocked 0ms 10-05 01:51:04.345: W/audio_hw_primary(109): out_write() limiting sleep time 63492 to 39909 10-05 01:51:04.353: D/dalvikvm(1196): GC_CONCURRENT freed 148K, 3% free 7460K/7687K, paused 10ms+0ms, total 13ms 10-05 01:51:04.389: W/audio_hw_primary(109): out_write() limiting sleep time 48616 to 39909 10-05 01:51:04.417: I/ActivityThread(1196): Pub com.adobe.reader.fileprovider: com.adobe.reader.ARContentProvider 10-05 01:51:04.437: W/ZZ(1128): BT_screen_pdfDoc:onStop JSON itemId: "50E2A4D6BC9FF315794D1A5" itemType: "BT_screen_pdfDoc" itemNickname: "21 (K-6)" 10-05 01:51:04.437: W/ZZ(1128): BT_activity_host:onStop 10-05 01:51:04.437: I/ActivityManager(307): START {cmp=com.adobe.reader/.ARViewer (has extras) u=0} from pid 1196 10-05 01:51:04.461: I/JNIInitializer(1196): Trying to load: /data/data/com.adobe.reader/lib/libAdobeReader.so 10-05 01:51:04.461: D/dalvikvm(1196): Trying to load lib /data/data/com.adobe.reader/lib/libAdobeReader.so 0xa69cedd8 10-05 01:51:04.601: D/houdini(1196): [1196] Loading library(version: 3.1.0.42836 RELEASE)... successfully. 10-05 01:51:04.601: E/dalvikvm(1196): The lib may be ARM... trying to load it [/data/data/com.adobe.reader/lib/libAdobeReader.so] using houdini 10-05 01:51:04.689: E/dalvikvm(1196): dvmHoudiniDlopen returns 0x99421f40 with bool=1 10-05 01:51:04.689: D/dalvikvm(1196): Added shared lib /data/data/com.adobe.reader/lib/libAdobeReader.so 0xa69cedd8 10-05 01:51:04.689: E/dalvikvm(1196): Calling h_NativeMethodHelper 10-05 01:51:04.701: E/dalvikvm(1196): Version returned : 10002 10-05 01:51:04.701: I/JPageView(1196): Trying to load 2: /data/data/com.adobe.reader/lib/libAdobeReader.so 10-05 01:51:04.701: I/JNIInitializer(1196): /data/data/com.adobe.reader/lib/libAdobeReader.so loaded successfully 10-05 01:51:04.741: D/dalvikvm(1196): GC_CONCURRENT freed 188K, 4% free 7694K/8007K, paused 11ms+0ms, total 13ms 10-05 01:51:04.773: D/dalvikvm(1196): GC_CONCURRENT freed 214K, 5% free 7915K/8263K, paused 12ms+1ms, total 15ms 10-05 01:51:04.785: D/dalvikvm(1196): WAIT_FOR_CONCURRENT_GC blocked 0ms 10-05 01:51:04.789: D/dalvikvm(1196): GC_EXPLICIT freed 34K, 5% free 7916K/8263K, paused 1ms+1ms, total 5ms 10-05 01:51:04.801: W/Settings(1196): Setting android_id has moved from android.provider.Settings.System to android.provider.Settings.Secure, returning read-only value. 10-05 01:51:04.805: V/PhoneStatusBar(384): setLightsOn(true) 10-05 01:51:04.813: D/OpenGLRenderer(384): TextureCache::get: create texture(0xb9461fd8): name, size, mSize = 65, 26892, 276680 10-05 01:51:04.841: D/dalvikvm(1196): GC_CONCURRENT freed 131K, 4% free 8185K/8519K, paused 11ms+0ms, total 14ms 10-05 01:51:04.849: D/(1196): HostConnection::get() New Host Connection established 0xb94c1dd0, tid 1196 10-05 01:51:04.961: I/ActivityManager(307): Displayed com.adobe.reader/.ARViewer: +520ms (total +669ms) 10-05 01:51:05.225: I/ActivityManager(307): No longer want com.android.settings (pid 551): hidden #16 10-05 01:51:05.233: D/OpenGLRenderer(1128): TextureCache::flush: target size: 62208 10-05 01:51:05.233: D/OpenGLRenderer(1128): TextureCache::callback: name, removed size, mSize = 1, 14848, 88832 10-05 01:51:05.233: D/OpenGLRenderer(1128): TextureCache::callback: name, removed size, mSize = 26, 256, 88576 10-05 01:51:05.233: D/OpenGLRenderer(1128): TextureCache::callback: name, removed size, mSize = 3, 14848, 73728 10-05 01:51:05.233: D/OpenGLRenderer(1128): TextureCache::callback: name, removed size, mSize = 4, 36864, 36864 10-05 01:51:05.233: W/ZZ(1128): tgfugamespe_appDelegate: onTrimMemory with level: 20 10-05 01:51:07.609: W/ThrottleService(307): unable to find stats for iface rmnet0
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/04/13 11:21 PM (12 years ago)
Just for kicks, try removing the spaces and stuff from the filename. Make '21 (K-6).pdf' something like '21_k-6.pdf' and see if that helps. Android really doesn't like spaces, caps and special characters in filenames. Mark
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/04/13 11:43 PM (12 years ago)
Hey Mark, Unfortunately, no dice. It's weird how there's no problem with opening PDFs in third party apps using the URL. I just get this feeling that the Android 3.0 Core is not set up for local PDF files... at least, not for easily sharing with an app like Adobe Reader... Any other possible suggestions? Thanks again, Mark, I appreciate it! -Nicholas
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/05/13 12:18 AM (12 years ago)
I'm a bit stumped! I'll try and work on this problem over the weekend. Mark
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/05/13 12:22 AM (12 years ago)
No problem, Mark, I appreciate your time & energy! I'll work hard on my end as well - thanks again! -Nicholas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/05/13 04:48 AM (12 years ago)
So, it'll work from a URL, but not locally? So far with my offline maps, I can only get them to work when I have the maps on the device SD Card. Have you tried putting the file on SD card and seeing if there was any results? There is some stuff Fred mentioned on the forums, I'll try and dig some up. They were concerning proper file path for Android Resources... In the meantime, maybe something like this could help? http://stackoverflow.com/questions/13616876/getting-file-path-for-local-android-project-files Cheers! -- Smug
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
10/05/13 05:58 AM (12 years ago)
I know Android will not work with spaces in the file names. I would recommend eliminating the spaces, even though that isn't the only cause of the problem. Also try removing the parentheses. It is interesting that "data" is in the path twice.
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/05/13 11:50 AM (12 years ago)
I probably should have mentioned that I've mounted PDF files to the SDCard and I get the same results within the app. When I choose to open the document with Adobe Reader, same error: "the document path is not valid" Interestingly, in this case, when I open the Adobe Reader application, I'm able to see, access, and read the PDF files (also, regardless of the file name having spaces and parenthesis). & Smug, I looked at the StackOverFlow link. The solution has 2 methods. The first, I can't seem to do at all as it won't let me place a file in the root folder (I get a "read-only" message). For the second, when I place one of my PDF files in the "src" folder, I don't get any messages, but the PDF file is not present within the folder. It just seems like this shouldn't be as difficult as it's proven to be... Thanks, everyone! -Nicholas
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
10/05/13 01:21 PM (12 years ago)
Ok, got it working. Check your PM. I will get back to everyone with this after someone else confirms it works for them too. Stay tuned. This was a fix done by David, and no your not crazy or doing anything wrong. There were a few problems with some code. Tim
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
10/05/13 01:22 PM (12 years ago)
Ha, looks like you don't allow PM. PM me with your email and I'll send you the three fixed files. Tim
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/05/13 01:25 PM (12 years ago)
Really?! That's odd, I've received PMs in the past - will look into this. I'll PM you my email, Tim, THANKS A TON! -Nicholas EDIT Changed PM settings!
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
10/05/13 01:32 PM (12 years ago)
Sent to Gracious, and Susan so if it works she can distribute it. Please post here and/or get with her if it works for you as well. Thanks to David for knocking this out for me/us. Tim
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/05/13 02:22 PM (12 years ago)
YES,YES, AND YES! Sorry for the Caps Lock, I can't contain my excitement! The code works 100%! Next up, submission to Google Play - time to read Buzztouch's How-Tos. :) Thanks a ton, Tim, and thanks a million to David for indeed knocking this out for me/us ;) -Nicholas THANK YOU!!!
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/05/13 10:15 PM (12 years ago)
Excellent that it got resolved! Is this a code fix to the Android v3 code that we all need to be aware of? Mark
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/05/13 11:07 PM (12 years ago)
Indeed! I'm not share what the exact code changes are, but the changes take place in 3 different .java files: BT_filemanager, BT_fragment, and BT_gcmConfig. If anyone is in need of viewing local PDF files in Android devices, feel free to message me! Thanks, everyone! :) -Nicholas
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
10/05/13 11:29 PM (12 years ago)
I have an app that relies heavily on that. Please send the code changes to MrkFleming at gmail dot com. Thanks! Mark
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/06/13 01:11 AM (12 years ago)
I wouldn't mind taking a peek as well. smugwimp at smugwimp dot com Cheers! -- Smug
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/06/13 01:17 AM (12 years ago)
Done & Done! -Nicholas
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/06/13 04:11 AM (12 years ago)
Thanks Nick :) Cheers! -- Smug
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
10/06/13 05:12 AM (12 years ago)
The gcm file fix was unrelated to the PDF issue, but stops a crash when accepting push notifications. Tim
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
10/06/13 10:30 AM (12 years ago)
We need to straighten all of this out in the plugins as well. At the same time, I have been working with Ian on a new plugin that handles PDFs much better for iOS only. (For Android, the code is identical to the current plugin.) Let me know if you are interesting in being a tester for the new plugin. It is called PDF Plus. It allows for bookmarks, swiping (the page automatically centers when you swipe), and it also has view that allows you to see all several pages at once.
 
GraciousWolf_PE
Aspiring developer
Profile
Posts: 372
Reg: Feb 15, 2012
Montreal
10,720
like
10/06/13 11:48 AM (12 years ago)
Absolutely, I would love to be a tester for the new plugin! Just the bookmarking feature alone would be tremendously beneficial with the other features being the cherry on top (at least, for my apps)! -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.