Tom Tom - 1 year ago 66
Android Question

Files downloaded don't have extension on some devices

I am stuck on a really tricky issue.
Context: My app is built to open files with a special extension (say myFile.png.myapp)

When I download it from my server using Chrome, it downloads fine and I get an "open" prompt and triggers my app, however, the path in the intent is in the form content://downloads/my_downloads/2136.

No extension.

For various reasons, the only MimeType I can send is application/octet-stream, so I have no way of knowing that file is indeed a png.

If I click on the notification that the file is downloaded it works fine.

This only happens for the moment on Nexus 5 running Android 6.0.1, on every other device, I get the actual file name and it's running smoothly.

I have both manifest and in app permissions set up.

My investigation leads me to think it's due to the Helpers class in the DownloadProvider package, but I'm not sure.

Can anyone assist?


Tom Tom
Answer Source

I ended up analyzing the headers of the file to extract file signature and determine MimeType. I adapted code found here

It's not perfect but coherent workaround.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download