I am trying to open pdf file
in chrome custom tab
, it works fine by using this code
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse("https://docs.google.com/viewerng/viewer?url=" +pdflink));
But the problem is, if the user have disabled chrome from app settings and there is no other browser it crashes. So how can i open it in the chrome custom tab if it is disabled.
Thanks in advance.
this is the exception that is showing up in the logcat.
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://docs.google.com/... (has extras) }
Try this:
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
try {
customTabsIntent.launchUrl(this, Uri.parse("https://docs.google.com/viewerng/viewer?url=" +pdflink));
}
catch (ActivityNotFoundException e)
{
// display message to user
}