For the future: Right-mouse in the Blocks work area and select "Download Blocks as image".
Your third activityStarter block:
should be DataUri not DataType
You should give a full path to the file:
You do not say what Android version you are testing? This may divine whether you can access that file path or not....
It is Android version 12.
You are correct that it should be DataUri instead of DataType - I just temporarily switched it to DataType for experimenting. When I had it to DataUri, and that path you displayed, I get "File not found (content://edu.mit.appinventor.aicompanion3.provider/external_files/Documents/Test.docx)
I want to open it in my app
Well the bad news is that it's difficult!
The docx format is a zipped, propriety XML format. So you will need a copy of Microsoft's docx specification and then:
- Unzip the file
- Load the file
- Decode the file (font styles, images etc)
- Render the result in your App.
Rendering a document could be done on a Canvas, but that would make everything a member of an un-modifiable image. Alternatively, you could Render the document as an HTML page (no internet required) but that requires a lot of work and skills in HTML and CSS.
Would it make a difference if it were a .doc as opposed to .docx?
Yes, a big difference, but a negative one as that format is not an open format.
To load a plain text file:
File_Load.aia (2.0 KB)
Ok, that would be helpful, as some of my documents would be text only. However some of the documents will have an image in them as well. I will try work arounds as the file I open does not necessarily have to be a Word.doc or Word.docx file. Perhaps a .pdf file would work, or be easier to work with? For a .pdf file, should I use DataUri and the same file path method?
If only viewing the PDF, that would work. There is an extension to try:
Thanks - so with this method, the phone would have to be connected to the internet in order to view the .pdf file? Also the documents I use would be very small - I'd say 2 pages max.
I don't have an answer for that - I would expect not. The best way to find out is to try it.
Ok, will do. Thank you very much for your help with all of this.
The ViewPdf extension is intended for local files, no internet connection required. If files are in the assets there is a helper extension for compiled apps.
i'm using activity starter in order to open and also to edit the word DOC and DOCX documents (see example below). But You have to install an MS WORD App or any other Word viewing APP on your smartphone.
The same approach is working practicaly with all types of files.
You only need:
- to have a related vewing app installed on your smartphone and
- to write in ActivityStarter.datatype the right mime type ( f.e for ZIP files - application/zip, for XLS files - application/vnd.ms-excel ...)
The activity starter will try to find and to open the right APP on your smartphone according to the mime type specified in ActivityStarter.Datatype.
That is of course possible, but it can take the User away from your App.
Hi, Alexandre. Thank you. I'm having difficulty finding the first purple "call" block - this is the same block attached to global MyFileName. Can you advise where to acquire it?
That is an extension by Taifun:
Thanks, I'll try that too