I am loading a page inside the webview
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://www.xxxxxxxxx/howtoguide.aspx");
then inside the webview I have several function to click event below
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains("[email protected]")) {
final Intent eIntent = new Intent(
android.content.Intent.ACTION_SEND);
eIntent.setType("plain/text");
eIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{"xxxxxx"});
eIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"");
eIntent.putExtra(android.content.Intent.EXTRA_TEXT,
"Text to be send");
startActivity(Intent.createChooser(eIntent,
"Send mail..."));
} else if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
startActivity(intent);
view.reload();
} else if (url.contains(".pdf")) {
//Intent intent = new Intent(Intent.ACTION_VIEW);
//intent.setDataAndType(Uri.parse(url), "application/pdf");
//try{
//view.getContext().startActivity(intent);
//} catch (ActivityNotFoundException e) {
//user does not have a pdf viewer installed
//}
// view.loadUrl("https://docs.google.com/viewer?url=" + url);
view.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=" + url);
} else {
view.loadUrl(url);
}
return true;
}
in this webview there is a click event for PDF. So if I click this the PDF not loading
view.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=" + url);
This method call working for me, when I called to load inside the webview. So this webview layout height should be match_parent.
Link click open the browser then simply pass the URL like below code.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
This is solved my problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With