zoom controller not working in webview in android - android

I am suffering from a strange problem in order to implement WebView in android. I am trying to load html5 supported web page in my WebView, but the problem is default zoom controller is not working in WebView.
i tried with the following code.
webview.getSettings().setBuiltInZoomControls(true);
webview.invokeZoomPicker();
Can any body help regarding this.

Add this line also
WebSettings setting = wView.getSettings();
setting.setBuiltInZoomControls(true);
setting.setSupportZoom(true);
if work or not please reply

Related

How do I get my android webview make a load locally

I have a doubt. What happens is the following:
I exported my game by using cocoonjs contruct 2, but I want to run it on my android webview by, because I want to implement starApp, and cocoonjs not support this.
So, using my code below, I get only a blank screen.
But in my launcher cocoonjs, this same project works normally, just that I select Canvas + can anyone help me?
web = (WebView) findViewById(R.id.webInicial);
web.setWebChromeClient(new WebChromeClient());
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("file:///android_asset/www/index.html");
webView.loadData(yourData, "text/html", "UTF-8");
Where youData is the actual HTML data.
Have you tried getApplicationContext().getAssets().open("www/index.html");?
If that doesn't work, I'd say try the solutions in this post and let us know if it worked for you.

WebView getting 404 on a good url

I'm getting a 404 in a webview using the following code . . .
LocateBrowser = (WebView)findViewById(R.id.locatebrowser);
LocateBrowser.setWebViewClient(new WebViewClient());
LocateBrowser.loadUrl("http://maps.google.com/maps?z=17&t=h&q=loc:31.8526,-110.9959");
If I copy that url into a browser on my PC, it works just fine.
If I don't implement the WebViewClient (the second line), the browser on the Android device opens up and displays the map properly. But I don't want it to do that, I want it to show in my WebView. The map looks like this in the external browser...
The problem is the above code first displays the screen above without the map and an indeterminate progress "Loading . . ." symbol for about a second and then displays google's 404 page saying "the URL /Search was not found on this server".
Is there something else I need to do?
Thanks,
Gary
What is wrong to use the WebViewClient ? If it works with that solution without using a the map api, that would be ok.
What is you aim ?
I failed to enable java script. Following code works but it produces a screen real estate problem.
LocateBrowser = (WebView)findViewById(R.id.locatebrowser);
LocateBrowser.setWebViewClient(new WebViewClient());
WebSettings webSettings = LocateBrowser.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setLoadWithOverviewMode(true);
LocateBrowser.loadUrl("http://maps.google.com/maps?z=17&t=h&q=loc:31.8526,-110.9959");

Embedded Youtube player getting cut off

I am trying to embed youtube video in my android app using WebView. Here is the code:
{
WebView mView = new WebView(getContext());
String embeded = loadPlayer(); // this is javascript string containing YtPlayer api
WebSettings webSettings = mPreview.getSettings();
webSettings.setJavaScriptEnabled(true);
mView.setBackgroundColor(535353);
WebChromeClient mChromeClient = new WebChromeClient();
mView.setWebChromeClient(mChromeClient);
mView.setWebViewClient(new WebViewClient());
mView.loadDataWithBaseURL("http://www.youtube.com", embeded, "text/html", "utf-8", null);
}
The problem I am having is my video gets clipped somewhere in the middle and the touch events on video don't work. Here is the link to screenshot:
Any ideas on what I am doing wrong here.
P.S. - This happens only on ICS 4.0.3 and it works fine on JellyBean 4.1
Any help is greatly appreciated.
I just got same type of error.
Here the problem is of Relative-Layout. Don't take Relative Layout when using Webview.
Always go for Linear-Layout. The time i changed Relative to Linear the View was Perfect.
You can turn off hardware acceleration and it fixes this issue for me. However, it does not play any longer on Amazon devices. I'm still looking for a fix to satisfy both issues.
webview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

Issue with WebView and Google Maps

In my application on click of a button i am trying to launch the following url using a web view :
https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore
My code is as below:
WebView webView=new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
webView.loadUrl("https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore");
When the web view appears it first displays the following:
And immediately displays the following:
I do not get to see the maps. Am i missing on something in my code. Can someone kindly help me with this please. Thanks in advance.
I had the same issue in using Google Maps URL into a ColorBox popup.
I found out that you can add &output=embed at the end of the URL to make it show in an iframe.
Maybe this solution will help you too.
So try:
webView.loadUrl("https://maps.google.com/maps?saddr=indiranagar bangalore&daddr=mgroad bangalore&output=embed");
i found that WebView does not support javascript by default, and this will lead google map jump to a URL that contains a params "nojs",
so, just add this line for your webview, problem gone.
webview.getSettings().setJavaScriptEnabled(true);

WebView Problem on Youtube site in Android?

i tried to load the url ww.youtube.com on my app in a webview. but it cant be load completely. it loads just like below image. in the browser it loads comfortably. why? Any Idea?
image http://www.freeimagehosting.net/uploads/d7356dd8e1.png
the simple answer is to call the youtube app thats loaded on every phone with your webview. check out the code on http://fluxkore.com/index.php/android-apps/ to call the youtube app.....
Enable JavaScript! =)
myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("http://www.youtube.com");
It might be a problem with WebViews - WebViews aren't fully fledged browsers, and have limited functionality. For example, the reference page specifically says that WebViews don't handle JavaScripts. If JavaScripts, Flash or something like that is required to properly load YouTube, then that could be why the WebView doesn't handle it properly.

Categories

Resources