Opening files on Android
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 38
- Joined: Thu Jun 28, 2012 2:48 pm
- Location: West-Cork, Ireland
- Contact:
Opening files on Android
Hi,
I understand that the browsercontrol under Android doesn't support the viewing of PDFs, docs, etc as it does on iOS.
Is there another way to get around that? Can you open a native or 3rd party app and have it display the file?
The files would be included in the app.
Many thanks,
Bert
I understand that the browsercontrol under Android doesn't support the viewing of PDFs, docs, etc as it does on iOS.
Is there another way to get around that? Can you open a native or 3rd party app and have it display the file?
The files would be included in the app.
Many thanks,
Bert
Re: Opening files on Android
Hi Bert,
you could try to launch the document:
...
put specialfolderpath("engine") & "/pdfs/my_doc.pdf") into tFile
launch url tFile
put the result into tResult
## Now check tResult:
## 1. if EMPTY, everything is fine
## 2. if -> "no association" then the device has not been set up to open/display PDF files
## 3. whatever but not empty, something went wrong
...
Check "launch URL..." in the dictionary.
Best
Klaus
you could try to launch the document:
...
put specialfolderpath("engine") & "/pdfs/my_doc.pdf") into tFile
launch url tFile
put the result into tResult
## Now check tResult:
## 1. if EMPTY, everything is fine
## 2. if -> "no association" then the device has not been set up to open/display PDF files
## 3. whatever but not empty, something went wrong
...
Check "launch URL..." in the dictionary.
Best
Klaus
-
- Posts: 38
- Joined: Thu Jun 28, 2012 2:48 pm
- Location: West-Cork, Ireland
- Contact:
Re: Opening files on Android
Hi Klaus,
Thanks for the reply, will give that a try.
Regards,
Bert
Thanks for the reply, will give that a try.
Regards,
Bert
Re: Opening files on Android
We may never know if Bert ever tried Klaus's code.
However I found myself trying something similar. I can get native Android apps to launch documents (e.g. PDF, text) outside the app on the target filesystem. However not for files copied over with the app. I check in my LiveCode app that the files exist, however the native apps return "failed to open this file" or "file cannot be opened". I’ve copied them over manually to check they will open with the apps on the Android device & they do.
Probably me doing something stupid but has anyone managed to successfully launch a PDF or text document copied over with the app on an Android device? Klaus, did you try your own code?
However I found myself trying something similar. I can get native Android apps to launch documents (e.g. PDF, text) outside the app on the target filesystem. However not for files copied over with the app. I check in my LiveCode app that the files exist, however the native apps return "failed to open this file" or "file cannot be opened". I’ve copied them over manually to check they will open with the apps on the Android device & they do.
Probably me doing something stupid but has anyone managed to successfully launch a PDF or text document copied over with the app on an Android device? Klaus, did you try your own code?
-
- VIP Livecode Opensource Backer
- Posts: 9834
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Opening files on Android
If you add a call to the sysError function where you're currently getting the error message, you'll get the ID of the error as returned by the OS.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 7233
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Opening files on Android
What syntax are you using? Are you using the "launch" command?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Opening files on Android
Thanks for replies.
An easy workaround is to copy the file(s) from the app specialfolderpath to an outside location and launch URL on that location. That works fine.
However I haven't seen any mention of success or failure of launching a file under the specialfolderpath on android so I'm curious about it.
Yes, as Klaus did:What syntax are you using? Are you using the "launch" command?
Code: Select all
put specialfolderpath("engine") & "/pdfs/my_doc.pdf") into tFile
launch url tFile
However I haven't seen any mention of success or failure of launching a file under the specialfolderpath on android so I'm curious about it.
Will try that shortly. As I mentioned, the right app tries to open the file but fails giving "failed to open this file" or "file cannot be opened".If you add a call to the sysError function where you're currently getting the error message, you'll get the ID of the error as returned by the OS.
-
- VIP Livecode Opensource Backer
- Posts: 7233
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Opening files on Android
Sound like it has to do with Android sandboxing. Normally an app is only allowed to access its own private files. There's an "external storage" option in the Android pane in standalone settings, which will allow your app to write outside its sandbox. You might have to resort to that. Write the file to a public location where other apps can access it.As I mentioned, the right app tries to open the file but fails giving "failed to open this file" or "file cannot be opened".
I haven't ever had to write to public folders so I'm not sure what the path would be but I think there are some references in the forum here.
Edit: I just noticed specialFolderPath("external documents"). Try that.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Opening files on Android
Klaus, Jacque - thanks for your replies.
Klaus: you should have said - I could have sent you my old phone. Then you would have no excuse. Although I expect it wouldn't be a welcome gift
Jacque: specialFolderPath("External Documents") worked. I think it should be in the dictionary entry for specialFolderPath along with at least a mention of Android sandboxing (sandboxing is mentioned for iOS so it's a little inconsistent). Now I've seen there is a pending bug report for it.
Best wishes,
Jim
Klaus: you should have said - I could have sent you my old phone. Then you would have no excuse. Although I expect it wouldn't be a welcome gift
Jacque: specialFolderPath("External Documents") worked. I think it should be in the dictionary entry for specialFolderPath along with at least a mention of Android sandboxing (sandboxing is mentioned for iOS so it's a little inconsistent). Now I've seen there is a pending bug report for it.
Best wishes,
Jim