Cannot open docx with intent


#1

Hi,
I’ve found an issue with opening docx, xlsx and pptx files.
We embed SmartOffice into our system, and sometimes our users need to view documents from email attachments.
Typical flow looks like this: user opens attachments list, pick a file and open it. We download file first, get it’s path, then launch SmartOffice activity like this:

Intent intent = new Intent(getActivity(), PicselViewer.class);
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.fromFile(new File(pathToFile)));

It works fine for all types of files, but in case of .docx, .pptx and .xlsx, Smartoffice throws an error “Cannot view this document”, and in logs I see this:

E/com.sol.fileviewer.support.BaseApplicationEventListener: 14:58:53.935 [main] ERROR - call onError: DOCUMENT_TRANSLATION_FAILED, false

or sometimes this:

E/com.sol.fileviewer.support.BaseApplicationEventListener: 15:07:32.349 [main] ERROR - call onError: DOCUMENT_AGENT_MATCH_FAILED, false

However, I’ve noticed that this behavior depends on file storage location. We store downloaded files in separate folder UserFiles in default files location, so path to a file looks like this:

/data/data/my_package_name/files/UserFiles/my_document.docx

But if I change this location to a default one:

/data/data/my_package_name/files/my_document.docx

everything works fine! It seems that it is only possible to open activity with file URI, which points to .docx, .pptx and .xlsx files only in default folder: /data/data/my_package_name/files. Opening files from any subfolders throws an error. Again, all other file extensions works fine, it happens only with .docx, .xlsx and .pptx files.
Please verify that issue and let me know if you can reproduce it or not. And also please describe in more details what the mentioned errors means.
All files are valid, cause I’m able to open them directly from SmartOffice file manager, both .doc and .docx.
Device: Nexus 5
Android version: 5.1
Smartoffice version: 2.3.32

Thanks in advance,
Gleb