After times of searching, I could not find the result for this:
My browser application is using webview, I need to use this function: currentwebview.setWebViewClient(). But I do not know how to get the current webview to apply that function.
I mean when I do not have the current webview id, then is there a way to get current webview for using setWebViewClient() ??
Thank you for your help !!
findViewById same as you would any view.
WebView currentWebView = (WebView) findViewById(R.id.my_web_viewId);
Related
The error occurred when I used Webview to create a webpage app. The error is "Cannot cast int to android webpage view".
I look forward to it solution
Thank you! in advance
You are missing a findViewById() call
Correct syntax is:
webView = (WebView) findViewById(R.id.webview);
Now in detail, you are trying to cast R.id.webview which actually return int ID value of the view that you have taken in XML layout and then you are trying to cast that directly into the Webview by writing a statement:
webView = (WebView) (R.id.webview)
And there it's showing incovertible types because you are trying to cast integer ID value into WebView. In Android, when you want to find views from XML then need to use findViewById() method.
use webView = findViewById(R.id.webview);
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.
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);
I'm using a webview in my app.
now what I want to do is to pass the data from my javaclass to html.
fro example I have a textview in my android javaclass and when I hit the button send the webview will show with html saying Hi + the name that I input in textview.
is it possible?
Check Using WebViews may be it will help
You can generate your html and then load it to WebView using loadData method for example.
Or you can use addJavascriptInterface to invoke methods of some Java object from javaScript code in WebView
See below code
WebView webview = (WebView) findViewById(R.id.webview);
webview.loadUrl("http://www.xxx.com/web/apps/jots.do");
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