I'm looking to securely download or view PDF and android files within an app from a URL. I'm successfully able to download and open PDF files by using the DownloadManager
or opening an intent with a URI as the argument. The same code will download a doc or docx file, but when I try to open the doc \ docx file on the android emulator (directly from downloads), I get "can't open file".
This is the code that opens an intent and downloads the docx \ doc file:
public void openWebPage(String url) {
Uri webpage = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
Do you know why I am unable to open these doc \ docx files?