I want to use two html in a single webpage so i choose to implement frameset in html. it works fine in all android version except android4.0. If i html file in default browser its working fine but in webview only one frame is loaded not the other ie first frame is override by second frame so it looks only second frame is loading.
here is my code for loading html in webview..
WebView web=new WebView(this);
String url="<html><frameset cols=\"25%,25%\" FRAMEBORDER=NO FRAMESPACING=0 BORDER=0><frame src=\"file:///android_asset/preview.html"
+"\" /><frame src=\"file:///android_asset/preview.html\" /> </frameset></html>";
web.loadDataWithBaseURL("file:/"+baseurl+"/",url, "text/html", "utf-8","");
i dont know why its not supporting in android4.0 whether android webview is not accepting frame in 4.0 or not? If anyone knows please help me..
Related
WebView wv = new WebView(this.context);
wv.loadDataWithBaseURL("file:///android_res/drawable/", "...<img src="my_pic.png ..."", "text/html", "UTF-8", null);
the html is actually in string, i just made it easy to read.
I used above code to populate some html to a WebView to display an image in drawable,
it is fine in debug mode, but a broken image icon results if I install a apk directly.
i am suspecting proguard, but seems doesn't make sense.
anyone experienced please help me ...
thank you
In my app , I am having a webview . In webview ,I am showing HTML content which is having tag , .I have 2 tabs in that which should switch on clicking on same place. But in webview they are coming one after the other.
In HTML file, I am calling method of Jquery file that method is not getting called . In browser its working fine. In iOS its working.
I am loading webview with base Url method only.
webView.loadDataWithBaseURL(pathToHtml, strLoad, "text/html","UTF-8", "");
These files are in assets . I am not sure that I am able to provide correct path for jquery files. So , I copied files to sdcard. There I am giving path. So path can not be the issue.
Please help me out . I tried many things but nothing worked. I am not getting what is the issue.
You can call a javascript function from webView.loadUrl("javascript:testFunction();"); to change the tabs insted of loading the page again. at the first load, you can use webView.loadUrl("file:///android_asset/index.html"); Befor using the jquery code, make sure that javascript enabled, set the webviewclient and webchromeclient for the webView.
I have a webview in my application which upon launch displays an html page. The page has a hyperlink which on click is supposed to display a video.
When i run the application and click on the video hyperlink link , nothing happens. But if i load the same page in android browser, then it launches a default video player and everything works fine.
I debugged it furthers by putting a log statement in shouldOverrideUrlLoading method and noticed that, when the hyperlink is clicked it gets redirected to another link and then to another link (final video streaming url).
My question is : why would the link work perfectly in default android browser and not through a webview.
Thanks
What is happening is when you click the hyperlink, that link probably has some popups inside of it. You need to define the onCreateWindow function in your webview's WebChromeClient. This handles how calls to open new windows or popups are handled.
public boolean onCreateWindow (WebView view, boolean dialog, boolean userGesture, Message resultMsg) {
((WebView.WebViewTransport) resultMsg.obj).setWebView(myWebView);
resultMsg.sendToTarget();
return true;
}
After declaring your WebView you should set javascript enabled, then your WebView will work as a browser.
For example:
WebView mwebview = new WebView(this);
setContentView(mwebview);
mwebview.getSettings().setJavaScriptEnabled(true);
or
mwebview.getSettings().setPluginState(PluginState.ON); // this is for newer API's
Basically, do not expect your embedded WebView works the same as Android default Browser. The default Browser is built on the same WebView, but there are lots a customization. (Especially around the no-standard uri, HTML5 stuff)
I followed code from here: WebView and HTML5 <video>, and I put the video link to a video tag, and I got the Video playing in my own version of WebView. The behavior is a little different from the default Browser. Given more time, we could figure that out by looking at its code, but anyways ...
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
I take the response from an HTTP connection in the form of string and show that to webview like this:
WebView engine = (WebView)findViewById(R.id.webview);
engine.loadData(endResult, "text/html", "UTF-8"); /*endresult is string*/
I actually get a response that contains the google page (google search result direct from google.com).
The loadData method works well i.e it shows the web page but when I click on one of the links on that page it shows "page not available" and said that "xyz link might be temporarily down or it may have moved to permanently to a new web address".
this happens for all links accept the first present link on that page. i.e it shows correct page from first link on that page but fails for others..
I noticed that OSes prior to 2.3 failed to follow links if setHorizontalScrollBarEnabled and setVerticalScrollBarEnabled are set to false.
try to use loadDataWithBaseURL of the WebView class
I would avoid using engine.loadData - it seems to cause all sorts of crazy problems.
Use engine.loadDataWithBaseURL instead, and pass the base URL of where the content exists. I would think that the content you are loading is using relative paths in it's HTML so it's looking inside your app resources. By specifying the base URL you get around this problem.