public void openDocumentWithInstalledApp(String filename) {
String mimetype = \"\";
url = url+ filename;
if (!url.startsWith(\"http://\") && !url.startsWith(
As an alternative you can try opening pdf in google docs. Try below code-
String pdfurl = "http://www.example.com/yourfile.pdf";
String googleDocsUrl = "http://docs.google.com/viewer?url="+pdfurl;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(googleDocsUrl ), "text/html");
startActivity(intent);