When I open pptx file through this link zoom is not working in android webview.
Here is the code that i'm using:
WebSettings setting = wView.getSettings();
setting.setBuiltInZoomControls(true);
setting.setSupportZoom(true);
In the OnCreate method, just put
webView.getSettings().setBuiltInZoomControls(true);
And it's working fine here.
For enable zoom option add this line of code.
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
Related
I have a problem with Android Web view.
The slider work fine with Apple but doesn't load on Android WebView.
Can anyone help? www.pgc-usa.net/ivynails
Thanks
I think I know. Web views in Android by default do not have JavaScript enabled. This is because there is someway it can do harm to the app. To enable it though it takes two lines
WebSettings webSettings = yourWebview.getSettings();
yourWebview.setJavaScriptEnabled(true);
You can also set it so that links that are clicked open in the web view. ( Otherwise they open in browser.) to add this you just add
yourWebview.setWebViewClient(new WebViewClient());
All that together will make it come to this:
WebView yourWebview = (WebView) findViewById(R.id.myWebview);
yourWebview.loadUrl("http://www.pgc-usa.net/ivynails");
WebSettings webSettings = yourWebviewgetSettings();
webSettings.setJavaScriptEnabled(true);
yourWebview.setWebViewClient(new WebViewClient());
You can find out more by visiting this page on the Android developer site by clicking this link.
I have an application in which I'm passing this URL to WebView.
Facebook URL
But the WebView is not displaying the page correctly.
The default android browser is displaying the content correctly.
Code
WebSettings wsettings = webView.getSettings();
wsettings.setBuiltInZoomControls(false);
wsettings.setSupportZoom(false);
wsettings.setJavaScriptEnabled(true);
webView.setScrollbarFadingEnabled(false);
webView.setHorizontalScrollBarEnabled(true);
wsettings.setUseWideViewPort(true);
wsettings.setLoadWithOverviewMode(true);
wsettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
wsettings.setAppCacheEnabled(true);
wsettings.setAppCachePath("");
wsettings.setUserAgentString("AndroidWebView");
wsettings.setDatabaseEnabled(true);
wsettings.setDomStorageEnabled(true);
webView.clearCache(true);
Please see the below screen shot for reference.
I have found the solution for this by removing the below code.
wsettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
wsettings.setAppCacheEnabled(true);
wsettings.setAppCachePath("");
wsettings.setUserAgentString("AndroidWebView");
wsettings.setDatabaseEnabled(true);
wsettings.setDomStorageEnabled(true);
webView.clearCache(true);
Add this options in your WebView code:
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setUseWideViewPort(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
if (Build.VERSION.SDK_INT < 8) {
mWebView.getSettings().setPluginsEnabled(true);
} else {
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
}
In my case, Facebook works perfectly.
Regards
I'm unable to open you tube into my application's webview on android 2.3 but on android 4.1 it works properly
here is the code
openWebLinkWebView.getSettings().setJavaScriptEnabled(true);
openWebLinkWebView.getSettings().setBuiltInZoomControls(true);
openWebLinkWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
openWebLinkWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
openWebLinkWebView.getSettings().setAppCacheEnabled(false);
openWebLinkWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
openWebLinkWebView.getSettings().setLightTouchEnabled(false);
openWebLinkWebView.getSettings().setUseWideViewPort(true);
openWebLinkWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
openWebLinkWebView.getSettings().setPluginsEnabled (true);
openWebLinkWebView.getSettings().setSupportMultipleWindows(true);
openWebLinkWebView.getSettings().setPluginState(PluginState.ON);
openWebLinkWebView.loadUrl(url);
you can use this code in your YouTube video Activity class
WebView web=new WebView(MyYouTubeActivity.this);
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("youtube_link");
setContentView(mWebView);
Yes i faced this issue before this is because the feature of android:hardwareAccelerated="true" is only available in API version greater or equal to 11 and in 4.1 it is by default enabled (you can enable/disable this in manifest at application level).
I had a problem like yours when playing on 2.3.3
The following worked for me.
webView = (WebView) findViewById(R.id.idWebView);
webView.setWebChromeClient(new WebChromeClient(){
});
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginsEnabled(true);
webView.getTouchables();
webView.setBackgroundColor(Color.parseColor("#00000000"));
String emdLink = "http://www.youtube.com/embed/" + video_code;
webView.loadUrl(emdLink);
Note: you should have embed + your video code.
Note also the above uses a deprecated call - in place of
webView.getSettings().setPluginsEnabled(true);
it should be better to use (untested):
webView.getSettings().setPluginState(PluginState.ON);
How can I perform click on WebView from java code? Is it possible to click on a specified location (x,y)?
WebView.performClick()
doesn't work!
You can do this by injecting javascript to your webview using loadUrl():
mWebView.loadUrl("javascript:<your javascript here>");
This example code will perform a click on the element with id 'button_submit':
mWebView = new WebView(context);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl("javascript:getElementById('button_submit').click();");
We have a webview that we are loading from android_assets. This works fine in 2.1, 2.2, and 2.3. However, when we load it in 3.0, we get a "Webpage not available" message.
This only happens on pages where we are passing parameters to the webview:
WebView webView = (WebView) findViewById(R.id.my_webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(new JavaScriptInterface(this), "androidInterface");
webView.setBackgroundColor(0);
//This works
webView.loadUrl("file:///android_asset/my.html");
//This does not work.
webView.loadUrl("file:///android_asset/my.html" + "?param=value");
Any idea how to get this to work on Honeycomb?
Not answer to the original problem, but a workaround. Since I was already using the JavascriptInterface, I set the value that I wanted to read in Javascript on the JavascriptInterface.