Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 9    Views: 432

NicoRacing
Lost but trying
Profile
Posts: 78
Reg: Oct 25, 2013
Hyeres
3,680
05/23/18 04:36 AM (6 years ago)

pdf plugin does not open file - Android.

Hi all ! Since BT version 4, the pdf plugin lost something on Android. If the option "download from URL" is chosen, the file does seem to get downloaded, but the Open button does not open it. If the option of a local file is chose, and making sure the pdf file is located in the Doc folder, there is a pop-up message stating that the file is not found, and the open button does not open anything. So I'm guessing there is a problem with the Open function ? Thanks to anyone who can help ! Good day Nico
 
NicoRacing
Lost but trying
Profile
Posts: 78
Reg: Oct 25, 2013
Hyeres
3,680
like
05/23/18 06:02 AM (6 years ago)
I now actually think it doesn't save in the cache... But I don't know how to check and correct that. ?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
05/23/18 07:30 PM (6 years ago)
In either android or iOS, there is a 'does cached file exist' method that I use, and have it write to the logcat. For android, something like this: string cachedFileName = "mydesiredfile.txt" if(BT_fileManager.doesCachedFileExist(cachedFileName)){ BT_debugger.showIt(cachedFileName + " exists"); }else{ BT_debugger.showIt(cachedFileName + " does not exist"); } Something like that should write to the logcat and let you know if it's there. Hope this helps! Cheers! -- Smug
 
NicoRacing
Lost but trying
Profile
Posts: 78
Reg: Oct 25, 2013
Hyeres
3,680
like
05/24/18 02:52 AM (6 years ago)
Hi Smug, you were my saver 2 years ago and here you are again ! :) While incorporating your lines, I actually found an original check for whether the file is in cache or not. In case the file is not in cache, it writes in the logcat ":handleEmailDocumentButton Cannot email document, document not in the cache?", and it is the case indeed. So the file is not saved in the cache. ***If I open a pdf that is stored in the Assets/Doc, I get this : 05-24 09:30:09.016 17159-17159/com.motorcyclevocabularylight W/ZZ: BT_fileManager:copyAssetToCache: MotoVocLight-Engine.pdf 05-24 09:30:09.017 17159-17159/com.motorcyclevocabularylight W/ZZ: BT_fileManager:copyAssetToCache :EXCEPTION java.lang.SecurityException: MODE_WORLD_READABLE no longer supported BT_fileManager:deleteFile MotoVocLight-Engine.pdf So somehow it is saved but then deleted ? ***If i download the pdf from URL, it does seem to be downloaded : 05-24 09:48:49.362 17159-17811/com.motorcyclevocabularylight I/ZZ_: finished downloading file finished downloading file ***But when I click on Open : 05-24 09:50:05.665 17159-17159/com.motorcyclevocabularylight W/ZZ: BT_screen_pdfDoc:openDocInCache. Calling helper method in BT_viewUtilities... BT_viewUtilities:openDocInCacheWithMimeType MIME Type: "application/pdf" 05-24 09:50:05.668 17159-17159/com.motorcyclevocabularylight W/ZZ: BT_viewUtilities:openDocInCache EXCEPTION android.os.FileUriExposedException: file:///data/user/0/com.motorcyclevocabularylight/files/F0636C41259096002B5CF0E_screenData.pdf exposed beyond app through Intent.getData() COULD THIS BE A MATTER OF LIMITED ALLOCATED MEMORY FOR THE CACHE ? HOW DO I CHANGE THIS VALUE ? Thank you !!! Nico
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
05/25/18 02:54 PM (6 years ago)
Hmm... Now it's starting to get a bit involved, lol! Which 'intent' are you compiling for? According to this: https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en anything beyond API 24 cannot use the 'file://' method to open a file. Things may need an update. Cheers! -- Smug
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
06/02/18 09:30 AM (6 years ago)
Smug, get a chance to try to update this old Android PDF doodad? Read that article above, looks easy enough. Easy enough for someone other than myself. Lol. Tim
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
06/03/18 09:43 AM (6 years ago)
Smug, get a chance to try to update this old Android PDF doodad? Read that article above, looks easy enough. Easy enough for someone other than myself. Lol. Tim
 
NicoRacing
Lost but trying
Profile
Posts: 78
Reg: Oct 25, 2013
Hyeres
3,680
like
06/05/18 02:37 AM (6 years ago)
Smug thank you very much for your input. I was away and didn't have a chance to say so earlier. As soon as I can I get my head back into it. Cheers Nico
 
tompos
Veteran developer
Profile
Posts: 127
Reg: Oct 19, 2013
Würzburg
7,370
like
10/15/18 04:10 AM (6 years ago)
Just a short update. I just run into the same problem and tried the following: I substituted the following part in function "openDocInCacheWithMimeType" in "BT_viewUtilities.java" ************************************ //make sure it copied... if(BT_fileManager.doesCachedFileExist(fileName)){ PackageManager pm = SyNA_appDelegate.getApplication().getPackageManager(); ApplicationInfo appInfo = pm.getApplicationInfo(SyNA_appDelegate.getApplication().getPackageName(), 0); File theFile = new File(appInfo.dataDir + "/files/" + fileName); ************************************ with ************************************ BT_fileManager.copyFileFromCacheToSDCard(fileName); File theFile = new File(SyNA_appDelegate.getApplication().getExternalCacheDir(), fileName); //make sure file exists... if(theFile.exists()){ ************************************ It simply copies the file from the app-specific cache to external memory that allows other apps to open the document. In this way all my "the file is corrupted and can not be opened" error messages went away and I could open the documents in Word, Google drive, EbookDroid,... Happy coding Thomas
 
NicoRacing
Lost but trying
Profile
Posts: 78
Reg: Oct 25, 2013
Hyeres
3,680
like
11/12/18 02:42 PM (6 years ago)
Hi Thomas, Thanks for your input on this matter. I have finally come to try it and I get and error when compiling stating in your lines : Cannot Resolve symbol 'SyNA_appDelegate' ? Cheers Nico
 

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.