I'm trying to load maps.google.com when user click a button with this url
http://maps.google.com/maps?saddr=40.702297,-73.796015&daddr=40.73682,-73.989937&mrsp=0,1
It works as I expected, but when I click
It load only partial of screen(not cover all my screen).
NOTE: I tried to load the same url in browser of emulator, everything is working fine.
Here is setting for the webview that I used to load a web:
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.webview_layout);
this.webview = (WebView)findViewById(R.id.myWebview);
WebSettings settings = webview.getSettings();
settings.setJavaScriptEnabled(true);
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
//....follow by normal setup of webview.setWebViewClient
}
I found a solution for this problem. In my webview I used a line of code in order to load Twitter website (without this line it will only load a white screen)
webSettings.setUserAgentString("Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3");
Related
We have a WebView based android app which loads webpage consisting <a> tags linking to YouTube video.
The web app works fine in a browsers like Chrome for Android and loads thumbnail from YouTube as expected but within WebView the <a> tag won't load the thumbnail of YouTube video.
How can we force the WebView to behave similar to Chrome browser
Have tried setting clients like below, which didn't help
webview.setWebViewClient(new WebViewClient());
webview.setWebChromeClient(new WebChromeClient());
Even added hardware acceleration in AndroidManifest.xml but it didn't work either
android:hardwareAccelerated="true"
Note: JavaScript is also enabled.
Did you try to enable javascript in your webview?
You can enable it like this:
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
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 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");
I've developed my own jQuery mobile project and host it on a website, it is available here:
http://thecoffeedrinker.site11.com/Youtube%20Theater/home.html
I can use this app from my mobile browser; now I would like to wrap it into an Android Application to publish it on Google Play. So I built a simple activity consisting into a webview, where I load the url:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_youtube_theater_wrapper);
WebView appView = (WebView) findViewById(R.id.pageView);
WebSettings webSettings = appView.getSettings();
webSettings.setJavaScriptEnabled(true);
appView.loadUrl("http://thecoffeedrinker.site11.com/Youtube%20Theater/home.html");
}
The problem is that the page is never displayed. All I get is the jQuery Mobile undefined progress bar, just like the loading is taking forever.
Is there any way to display the pages properly?
Add this to your webView:
webSettings.setDomStorageEnabled(true);
So:
WebView appView = (WebView) findViewById(R.id.pageView);
WebSettings webSettings = appView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
appView.loadUrl("http://thecoffeedrinker.site11.com/Youtube%20Theater/home.html");
try this into your java file
appView.loadUrl("http://thecoffeedrinker.site11.com/Youtube%20Theater/home.html");
appView.setIntegerProperty("loadUrlTimeoutValue", 100000);