JqueryMobile scroll not working in webview (Android 2.3) - android

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");
}

Related

YouTube thumbnail won't load in webview

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);

Chrome Web View not active on tablet

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?

Jquery datepicker not showing in Android Webview. Works in native browser

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);

Select change Event not working on Android WebView

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);

Open external page in InAppBrowser android 2.3 doesn't work

i have this little issue, in iOS InAppBrowser works well, but in android no way, i turn on all external page in white list, i put a console.log to see if method is called, but doesn't open here how i handling with that
link : a href="#" onclick="openInAppBrowser('my link);" class="recents">
and the method
enter code here
function openInAppBrowser(url){
console.log('click in app brownser');
console.log('page: ' + url);
window.open(encodeURI(url), '_blank', 'location=yes');
}
Any idea? In iOS works fine but in android no way, if any one could help me
Did you enable JavaScript on your webview?
http://developer.android.com/guide/webapps/webview.html
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true)

Categories

Resources