i need help, my WebView not show website's video player(black square)
But, it is working on phone browser.
Also, i have tried to use some advanced webview from github, same result(balck square).
This my code
webView = (WebView) findViewById(R.id.webview);
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true);
settings.setDatabaseEnabled(true);
settings.setSupportZoom(true);
settings.setDisplayZoomControls(true);
settings.setBuiltInZoomControls(true);
settings.setAppCachePath(getApplicationContext().getFilesDir().getAbsolutePath() + "/cache");
settings.setDatabaseEnabled(true);
settings.setDatabasePath(getApplicationContext().getFilesDir().getAbsolutePath() + "/databases");
webView.getSettings().setUserAgentString("wp-android-native");
//webView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; Android 4.1.1; HTC One X Build/JRO03C) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.58 Mobile Safari/537.31");
webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());
//webView.setInitialScale(100);
webView.loadUrl("http://onlinemoviesbox.com");
Can you please comment below line and check once , am able to play youtube video properly
// webView.getSettings().setUserAgentString("wp-android-native");
Related
I'm using a webview to open a website. The problem I'm getting is after user clicks on a button, it always get stuck to the Loading dialog and doesn't show the expected results. But in Google Chrome or custom tabs, it works perfectly fine. I'm not overriding onPageFinished(), onPageStarted() or any other webview method, they are as it is. These are my webview settings:
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setDisplayZoomControls(false);
webView.getSettings().setSupportMultipleWindows(true);
WebSettings settings = webView.getSettings();
settings.setDomStorageEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setAllowUniversalAccessFromFileURLs(true);
settings.setAllowFileAccessFromFileURLs(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
String newUA= "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0";
webView.getSettings().setUserAgentString(newUA);
webView.clearFormData();
webView.getSettings().setSavePassword(false);
webView.getSettings().setSaveFormData(false);
webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(true);
Just wanted to know what settings could be different in custom tabs and my webview that's causing the issue. And I think it's probably not possible but still asking is there any way to imitate the browser settings of custom tabs for the webview so that I can check if it works that way
I have a page that got elements that when long clicked makes it draggable. It works on the Chrome app but not on my WebView.
This is my WebSettings.
String UA = "Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19" +
" (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19";
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
settings.setPluginState(android.webkit.WebSettings.PluginState.ON_DEMAND);
settings.setDatabaseEnabled(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
settings.setDomStorageEnabled(false);
settings.setUseWideViewPort(true);
settings.setAllowFileAccess(true);
settings.setAppCacheEnabled(true);
settings.setUserAgentString(UA);
I also already enabled long click on the webview by doing webView.setLongClickable(true);
I can now drag the elements after long clicking. But I can only drag 1. After dragging 1 element, I can't drag anything anymore.
The page the webview loads GSAP TweenMax, Draggable, CSSPlugin if that infos will help.
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 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>";
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.