I have a phone, Galaxy S4 and a tablet, Galaxy Tab both running Android 4.4.2.
I'm running a custom app that loads a Chrome Web View:
mWebView.setWebViewClient(new MyWebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.setWebContentsDebuggingEnabled(true);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
mWebView.addJavascriptInterface(this, "Android");
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.setAcceptThirdPartyCookies(mWebView,true);
} else {
cookieManager.setAcceptCookie(true);
}
This works absolutely fine on the phone, however on the tablet, certain css rules are not being applied:
transform: rotate(180deg);
I do not have the -webkit prefix, but since it works on the phone, it leads me to believe that it is using the default webview and not the Chrome one
http://caniuse.com/#feat=transforms2d
Also, I can attach the chrome desktop browser inspect tool while debugging to the phone, but not to the table.
Is there any reason why a Chrome Web View would not load on this device?
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've created a webapp using jquery Mobile and I'm rendering it on a native app via a webview. It works nicely with Android 4+ devices, but using a Gingerbread device the scroll simply doesn't work.
Loading the website directly on the device's browser does work, it's just on the webview of my app. This is how I create the webview:
mWebView = (WebView) findViewById(R.id.webView);
mWebView.setFocusable(true);
mWebView.setFocusableInTouchMode(true);
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
WebSettings s = mWebView.getSettings();
// s.setUserAgentString(Constants.USER_AGENT);
s.setRenderPriority(RenderPriority.HIGH);
s.setJavaScriptEnabled(true);
s.setDomStorageEnabled(true);
s.setDatabaseEnabled(true);
s.setAppCacheEnabled(true);
s.setSupportZoom(true);
s.setBuiltInZoomControls(true);
s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
s.setUseWideViewPort(true);
s.setLoadWithOverviewMode(true);
s.setSavePassword(true);
s.setSaveFormData(true);
s.setJavaScriptEnabled(true);
Any suggestions on where the problem could be?
Turns out it was because of the CSS property overflow:hidden being set on the body by jQuery Mobile. I set it to auto for my pre Honeycomb devices and seems to be working okay.
In case anyone is interested, here's what I did using jQuery:
function isAndroidBelow3() {
return !!navigator.userAgent.match(/Android [1-2]/i);
}
if(isAndroidBelow3()){
$(document.body).css("overflow", "auto");
}
I have this piece of code on my WEB APP:
$(document).on('pageinit', function(){
$(".radius").on('change',function(){
$("#cercadeMiForm").submit();
});
});
No if I run this on my website, every time I change selection on the combo with class "radius", my form gets submitted properly.
If I run it on my mobile device standalone browser app, it works as well.
However, when I run it in my own app's webview, it does not work. I am using jQueryMobile and it seems to be working okay so I guess it's not a jQuery thing.
This is where I initialize my WebView:
mWebView = (WebView) findViewById(R.id.webView);
mWebView.getSettings().setUserAgentString(Constants.USER_AGENT);
mWebView.getSettings().setBuiltInZoomControls(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
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");