Force WebChromeClient instead of WebViewClient - android

I am currently working on a mobile android app containing webcontent into a WebView.
As far as i understood well, some phones used WebChromeClient, some other WebViewClient, I guess depending on Android version.
My app works well, but I found some CSS rendering issues. If i fix them on classical webview, chromeClient is broken, and opposite :)
Tested on my S3 (android 4.3) seems to use WebViewClient
and MotoG (android 4.4) seems to use WebChromeClient.
Any advice to deal with that ? Is there anything to do to force one of webview client on every device ?
Thanks a lot

Android 4.4 (API level 19) has introduced a new version of the WebView that is based on Chromium. That might be the reason why you get different renders on your S3 and your Moto G.
Setting your targetSdkVersion in your manifest file to 18 or lower will make your WebView for API 19 and higher operate in "quirks mode" which means that it will try to have the same behavior as you would have on a lower API device.
See the android documentation for more details. I hope that solves your problem.

Related

Android webview app not working properly in Android 4.4 or lower

I have create one Android app using android webview. I am using jQuery mobile. I am also using Admob and javascriptInterface in that. The app is working fine in Android 5.0 and higher, but it is opening and stucking on pageload in lower versions of Android.
I have set minimum API level to 15 and max to 26.
What could be the possible reason for this?
Thanks in Advance!
I found the solution for this problem.
WebView in 4.4 or lower versions of android does not support CSS animations, that caused my page to stuck.
So, I used -webkit- vendor prefix for chrome, then it worked fine.

How can I inspect webview content on older Android versions? Specifically older than 4.3?

I'm trying to inspect an app in Android 4.2 and 4.3, i'm able to inspect this devices using chrome (https://developer.chrome.com/devtools/docs/remote-debugging), but I need to test this on Webview, i didn't find a solution.
Some css are rendering different from newer versions of Android. HTML5 and CSS3 are suported in Android 4.3 webview ??
Currently there is no straight forward way to debug . one solution is to override the onConsoleMessage[which is used to print console statements],onJsAlert [used to show the alerts] methods of WebChromeClient attached to that webview ,get the logs and alerts , based on that upto some extent we can debug. Hope this solution helps you.

how to use webview v30 in android 4.3

All,
My webpage contains html5, it is OK on ANDROID 4.4, while something wrong on ANDROID 4.3.
After google it, I found
Android 4.4 update the webview.
Is it possible to use new webview on ANDROID 4.3(or 4.X)?
No, not directly.
You may like to investigate the XWalk Project[1]. However, some things to be aware of:
it is not a drop in replacement for WebView. Some APIs are missing or work differently
there is a significant increase (~25MB) to your APK size, and RAM size will increase too.
[1] https://crosswalk-project.org/

Android Webview looking poor quality than system browser

I have developed a webview in android application which renders existing web application. I considered target sdk as 8. After development application works perfect in Samsung devices(ICS) but when I test the same in my Asus(ICS) tablet the quality is very poor, everything looks blurred whereas the same looks perfect when i test in it's system browser.
Any relation to hardware? please suggest me some way..
Thanks in Advance
Try to change the minSDK level to 11. and enable hardware Acceleration in the application manifest at application level.

Why is PhoneGap slower than Browser?

I'm running the same exact web app on Android under PhoneGap and under the built in Browser. The app runs fine on the built-in browser but is unbelievably slow under PhoneGap. Even basic scrolling on the page stutters under PhoneGap.
Is there anything, in general, that I might be doing wrong? I was under the impression that PhoneGap just uses the same WebKit renderer as the normal Browser app, so why would the same HTML and JavaScript run much slower inside PhoneGap?
P.S. This has been asked before, but due to wording I think the original question was misunderstood.
I may have inadvertently stumbled on an answer to this. Turns out that the apps I was working on had android:targetSdkVersion in AndroidManifest.xml set to a really low value (i.e. my target Android version was something like 2.2). Increasing this to 14 (Android 4.0) appears to have hugely improved PhoneGap performance, at least on newer Android devices running ICS or Jelly Bean.
Setting a low targetSdkVersion seems to disable at least some of the performance improvements introduced in newer versions of Android.
So, if you want to see a big performance boost in PhoneGap, make sure your targetSdkVersion matches the max SDK version supported by the phone you're testing on.
I don't know phoneGap, but you can try these:
Adding android:hardwareAccelerated="true" in the manifest
If you use webview webview.getSettings().setRenderPriority(RenderPriority.HIGH); and webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
It is counter-intuitive but you may actually need to turn off hardware acceleration for your webview. Hardware acceleration as of Android 4.0.4 does nothing for canvas and other redraw events, but actually removes CPU resources for those events.
Try adding this line of code in your app java file:
super.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Also set android:hardwareAccelerated="false" in the manifest.
Same exact thing I experienced! Previously I was using Android 3.x for testing. As soon as I upgraded to 4.4.2 my Canvas was dead slow! Looking at the Rendering timeline I could see many Rasterization calls taking over 100ms and reducing my FPS to about 8! android:hardwareAccelerated="false" solved my issues. Is there a way to set hardwareAccelerated="true" depending on android version?

Categories

Resources