Reputation: 11
String googleDocsUrl = "http://docs.google.com/viewer?url="+urlPDF;
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(googleDocsUrl ), "text/html");
startActivity(intent);
But it leaves the current activity and it open in google doc url. I want to open it in my current activity in a webview. Please advice and if possible provide an example.
Upvotes: 1
Views: 311
Reputation: 629
webView = (WebView) findViewById(R.id.webView_medicalpricing);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
if (mDialog.isShowing()) {
mDialog.dismiss();
}
}
});
webView.loadUrl("http://www.google.com");
return true;
Upvotes: 0
Reputation: 1326
you should add something like this to your shouldOverrideUrlLoading:
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url != null )) {
view.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
if( url.startsWith("http://docs") || url.startsWith("https:") ) {
return false;
}
Upvotes: 0