title: How to open excel, doc files with intent from my app in MS-Excel or MS-Word - Android
body: <p>My requirement is to download and view the Excel, Doc files in my app. So I downloaded the Excel/Doc file in phone storage and called the ACTION_VIEW Intent by passing the file path. Then I got this error saying "Try saving the file on the device and then opening it."</p>
  
  <p><img src="https://i.stack.imgur.com/y4WoC.png" alt="This is Error ScreenShot"></p>
  
  <p>I can be glad if any one can suggest me another alternatives as well to open excel or doc files. Please guys i have searched a lot for this so far i didn't find the solution and i am sure that i have used proper intent for opening files.</p>
  
  <p>Where My Code:</p>
  
  <pre><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();
  
                  }
  </code></pre>