My requirement is to download and view Excel, Doc files in my application. So I downloaded the Excel / Doc file to the phone’s memory and named ACTION_VIEW Intent, passing the file path. Then I got this error: "Try to save the file on the device, and then open it."

I can be glad if anyone can offer me another alternative to open excel or doc files. Please guys, I have searched a lot for this so far, I have not found a solution, and I'm sure I used the right intention to open the files.
Where is my code:
Intent intentpdf = new Intent(Intent.ACTION_VIEW);
intentpdf.setDataAndType(Uri.parse(message), "application/msword");
intentpdf.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
mactivity.startActivity(intentpdf);
} catch (ActivityNotFoundException e) {
if (!mactivity.isFinishing())
Toast.makeText(mactivity, "Install MSWord Viewer.", Toast.LENGTH_LONG).show();
}
Intent intentpdf = new Intent(Intent.ACTION_VIEW);
intentpdf.setDataAndType(Uri.parse(message), "application/vnd.ms-excel");
intentpdf.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
mactivity.startActivity(intentpdf);
} catch (ActivityNotFoundException e) {
if (!mactivity.isFinishing())
Toast.makeText(mactivity, "Install Excel Viewer.", Toast.LENGTH_LONG).show();
}
source
share