I try to open pdf url in my webview with below code , i found solutions with gdoc but it is not useful for me because I want to show pdf only in view mode and user should not download and also need to clear cache after back press
code :
mWebView.setWebChromeClient(new WebChromeClient());
WebSettings settings = mWebView.getSettings();
settings.setPluginState(WebSettings.PluginState.ON);
mWebView.setWebViewClient(new MyBrowser());
mWebView.setBackgroundColor(0x00000000);
settings.setAllowFileAccess(false);
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(false);
settings.setSaveFormData(false);
settings.setJavaScriptEnabled(true);
use this code:
WebView webView = (WebView) findViewById(R.id.my_webview);
webView.setWebViewClient(new MyWebViewClient());
webView.addView(webView.getZoomControls());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://docs.google.com/gview?embedded=true&url=**PDFurl**");
also, add permission in manifest as it needs internet connectivity (must required)
<uses-permission android:name="android.permission.INTERNET"/>
this will work!
if direct url not work then lode this
webView.getSettings().setPluginsEnabled(true);
webView.getSettings().setAllowFileAccess(true);
webView.loadUrl(pdf);
also,
String pdf="<iframe src='http://docs.google.com/viewer?url=+location to your PDF File+'
width='100%' height='100%'
style='border: none;'></iframe>";
Related
I have created an android app for a simple website view (Using webview) but I can't select file using
I am trying to make a app which completely load the website made using php
use your Web view in this way .
webview =(WebView) findViewById(R.id.webView);
WebSettings webSettings=webview.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setDatabaseEnabled(true);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl(url);
I want to load a website in android webview which has pretty good design but in webview only html content is showing. I don't have experience with Web but I think the CSS is not loading.
webView = (WebView) findViewById(R.id.webView);
webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setDomStorageEnabled(true);
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webView.loadUrl(myURL);
webView.setWebChromeClient(new ChromeClient());
webView.setWebViewClient(new MyWebViewClient());
Its working fine in iOS webview and in browsers.
Please help. Thanks!
I am trying to build a apps which will be able to youtube and dailymotion ...
youtube is ok but dailymotion is not load fully,it load's only menu bar with click restricted(no touch allowed)...How will i solve it,any idea please...
My sample code for loading WebView is here
webView.setWebViewClient(new myWebViewClient());
webView.setWebChromeClient(new myWebChromeClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSaveFormData(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.loadUrl("http://www.dailymotion.com");
output window:
I have gotten a solution that can solve this problem..i have given my code here if would be beneficial..
webView.setWebViewClient(new myWebViewClient());
webView.setWebChromeClient(new myWebChromeClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSaveFormData(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.getSettings().setDomStorageEnabled(true);
webView.loadUrl("http://www.dailymotion.com");
I'm trying to embed an HTML page in a webview. The page has some jquery and javascript. When an input field is clicked it brings out the jquery datepicker. It works well in the native browser but, doesn't work in the webview. I did set enableJavascript to true but still not showing. So I'm not sure how it works if opened in the native browser, but not if is in webview. Am I missing anything? Any help is appreciated. This is my code:
myWebView = (WebView) findViewById(R.id.webView);
//Enable Javascript
WebSettings webSettings = myWebView.getSettings();
webSettings.setLoadWithOverviewMode(true);
//Enable DOM Storage
webSettings.setDomStorageEnabled(true);
//Enable Zoom
webSettings.setBuiltInZoomControls(true);
//I was adviced to place some of this to handle page navigation:
myWebView.setWebChromeClient(new WebChromeClient());
myWebView.setWebViewClient(new WebViewClient());
//other settings
myWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
myWebView.setScrollbarFadingEnabled(false);
//finally, load url
myWebView.loadUrl("https://www.mycustomurl.com");
You have to enable Javascript in your webview...
like this,
WebView.getSettings().setJavaScriptEnabled(true);
in your code, add this too..
webSettings.setJavaScriptEnabled(true);
Video isn't working and not fullscreen inside webview:
WebView web = (WebView) findViewById(R.id.webview);
WebSettings webSettings = web.getSettings();
webSettings.setJavaScriptEnabled(true);
web.getSettings().setJavaScriptEnabled(true);
web.setWebViewClient(new MyCustomWebViewClient());
web.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
web.loadUrl("url/");
Have you enabled hardware acceleration in you app?
Have you implemented WebChromeClient.onShowCustomView?
There is a section on the pieces needed to enable HTML5 fullscreen video at http://developer.android.com/reference/android/webkit/WebView.html.