Joe Rakhimov
Joe Rakhimov

Reputation: 5083

Docx file download

I am trying to download .docx file. I would download using HTTP connection. But link is not direct link. So I am using intent to open url in browser. Consequently, browser will download it.

            String url = "http://dev.businessinfo.uz/document/template/download/link/528b07d162135";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);

Problem is file is downloaded in bin file extention which can not be opened by doc viewer application.

enter image description here

How to solve this problem?

Upvotes: 0

Views: 1637

Answers (1)

VVB
VVB

Reputation: 7641

The problem is not in your code, it happens when you use native browser. At that time it downloads file in ".bin" file format.

However, if you use chrome then it will download in ".docx" file format. I just tested your code. It works fine & I get that file in ".docx" file format. You need to download it via android google chrome browser.

So I recommend you to open android mobile google chrome browser while calling implicit intent for opening/choosing browser for downloading file

Here I'm giving you link for the problem of automatic extension conversion while downloading file in native android browser.

Reference link :

Avoiding content type issues when downloading a file via browser on Android

Upvotes: 1

Related Questions