Is Android Webview is same as the Chrome browser? - android

I am having the webview, which will be created using the following code.
WebView mWebView=new WebView(this);
mWebView.setWebViewClient(new WebViewClient());
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.addJavascriptInterface(new AndroidJavaInterface(), "JavaInterface");
Is this webview is same as the chrome.? If I am loading any URL into this webview using loadurl() method, and running in two different devices, Is the webview is same in all the devices?. I think it will run on the customized mWebView or Is the app pick the device's default browser for loading URL?
EDIT 1: I have created the webview in android version 2.2. That is API 8. If I am running the app in android 4.1 device. Is the webview version is changed or the webview is remain same for all the devices with different versions?

No, Webview widget is not Chrome.

You can implement a WebView adding some behaviour like Javascript and Java, but IT WILL NEVER BE LIKE A BROWSER (less performance,less capability...).

Well according to my knowledge WebView and Chrome browser are different.
WebView is an Android widget which is used to display local and remote web pages. Even though it has got some features of a browser like rendering JavaScript, it cannot be considered as a fully fledged browser.
Please refer Developer Site for more details.

Related

Disable webview browser tester ( android )

I download last version of android studio , keep all up to date.
VERSION is 2.2.2 .
I cant find how to remove tester browser from my app . I just wanna to use webView control not browser tester .
I fixed it. I forgot to add this line:
WebView.setWebViewClient(new WebViewClient());
What heppend was that it actually opened the browser after redirecting instead of the WebView.
For some reason it opens this webview tester instead of the browser, so it's misleading.
Full code:
WebView webview = (WebView)findViewById(R.id.webView);
webview .setWebViewClient(new WebViewClient());
webView.loadUrl("https://...");

Android webview from angularJS website. Not able to get redirect url

I have a website built using angularJS. Now I want to make an Android application using webview and some native code. So I want to get all redirect urls on click of anything in website, so that i can judge whether it to be loaded using angular or native. Since angular is doing internal routing I'm not able to get url using shouldoverrideUrlLoading from Andfroid.
Can someone please give a workaround. Or please help me in transferring data from angular to Android using javascriptInterface
You cannot transfer data directly from Angular to Android as angular is used at the client side of the application.
Why not use the same Rest API which if you are using and consuming in Angular Application. Use the same API in Android to get the data.
So, Basically the interaction of data should happen between your webserver API and Android.
If you just want to see the html page in android on click of that href link. Use WebView widget in android.
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.com");
You can read more about it in developers doc..
http://developer.android.com/reference/android/webkit/WebView.html

Android Webview Performance differences

I am writing a webview app in android 4.4.3 the latest Android version.
But my biggest Problem is the performance differences between the chrome browser and my webview app.
The differences are huge.
How can I get the webview app to the same performance as the chrome browser?
Try this code. It will help you in increasing the speed -
webview.getSettings().setRenderPriority(RenderPriority.HIGH);
webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
Also try adding this to Manifest under desired activity -
android:hardwareAccelerated="true"
EDIT
Chrome does not use webview - source.
Does this mean Chrome for Android is using the WebView?
No, Chrome for Android is separate from WebView. They're both based on the same code, including a common JavaScript engine and rendering engine.
That is probably the only reason for the performance difference

open the content in chrome browser phonegap

I need help resolving the error I get when I run a phonegap android app. I'm iframing a page with an embedded UStream feed. Everything else loads perfectly expects the ustream section and I get the error:
Sorry! The stream could not be played on this device.
Open the Content in Chrome Browser
Any assistance you can offer will be greatly appreciated.
Probably what is going on is that the UStream feed uses some HTML5 or other fancy API that is not yet in the WebView that Cordova/PhoneGap uses. You see, Phonegap uses a native WebView component to render the HTML content of your app. The problem is that this WebView is an oooold version of WebKit and doesn't support HTML5 and some other things. This is why the same web page will sometimes act differently depending on if you open it with Chrome browser, the standard Android browser, or with a Cordova WebView. This problem exists for all platforms as far as I know.
The slightly good news is that they just announced that Android 4.4 will have an updated WebView based on Chromium code, so hopefully your iframe will work in a 4.4 version of Cordova.

Play Youtube HTML5 embedded Video in Android WebView

I am having a problem running a HTML5 Youtube embedded in a WebView.
I want to play a Youtube video on my application. I decided to use WebView instead of VideoView, because I want to make my system more flexible to play video from web.
Although There are many ways to get play youtube on the android, but I will use the youtube embedded version. "http://www.youtube.com/embed/___________________". Because this is one of the solution I found when your android doesn't support flash.
The problem:
The WebView load as normal including the embedded Youtube. But I get a black screen on the youtube at start.
When I click on it. It load the first Image only but then It is not Playing. I tried to play on the android browser, it works smoothly but not in the webView.
Any idea why?
Below is just a snip of my code:
WebView wv = new WebView(getApplicationContext());
wv.getSettings().setPluginState(PluginState.ON);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadUrl("http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html");
setContentView(wv);
Here are some of the resources that I found very useful:
How can we play YouTube embeded code in an Android application using webview?
play youtube video in WebView
How to embed a YouTube clip in a WebView on Android
http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html
http://www.broken-links.com/2009/10/06/building-html5-video-controls-with-javascript/
http://www.youtube.com/embed/bHQqvYy5KYo
Thank you in advance for any support and help :)
Update (13 June 2011):
I successfully load the http://m.youtube.com inside the WebView, but unable to play any video. But When I tried to load the URL on my Android Browser, it can play.
From here, I notice that the youtube site from my WebView is not signed in. So How can we allow the WebView to use the same credential as my Youtube account in my phone? Will it actually works?
Step 1 : Simply add this to Manifest file
android:hardwareAccelerated="true"
step 2 : check if you are setting layer for your webview.
(i.e.)
//myWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
setting hardware acceleration to true and commenting these lines worked for me .
To know more about Hardware Acceleration and Layers look here at http://developer.android.com/guide/topics/graphics/hardware-accel.html
EDIT
So from the comment conversation we have deducted:
On this website: www.youtube.com/html5 it says you have to sign in then opt in for HTML5 video playback
That is why your video will not load, it is redirecting to a flash version and your webview does not have flash.
ORIGINAL
Are you overriding url loading so your webview is being used?
wv.setWebViewClient(new WebViewClient(){
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
});
Are you saying the video won't play but the website loads?
You could try lying to YouTube and telling them your a different browser (perhaps pretend to be the android browser) Firefox is:
wv.getSettings().setUserAgentString("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.36 (KHTML, like Gecko) Chrome/13.0.766.0 Safari/534.36");

Categories

Resources