I need to send from server side simple web pages (with images) some how (mht, or zipped web page folders) and show it on UI of my Android application without browser control, can someone advice my how to proceed with that on Android device?
To show a web page in your app, there are two ways to do it: use the default Browser of Android, or use a WebView. For the second one, you can do this:
WebView webView = (WebView)findViewById(R.id.webView);
//you can load an html code
webView.loadData("yourCode Html to load on the webView " , "text/html" , "utf-8");
// you can load an URL
webView.loadUrl("http://www.stackoverflow.com");
layout XML :
In your layout Xml, define an WebView like this:
<WebView android:id="#+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
You can use the WebView which is an HTML rendering engine that can be dropped into your application just like any other view. It isnt a full browser though, so you control it from your own application logic.
Related
Android use webview to load web pages such as facebook I would like to load the video tag in the label below the button, such as the following figure:
How to do like this?
I have a simple Activity to show a webview and a back button. Here is the code that I use to load the URL that I want in the webview.
The webpage that I am loading in on a server online, it has a few form elements plus a few links that when clicked I need to keep loading them inside the webview.
Now the problem is very often the page loads without the images, I can see the form elements though or only blank white page. I am testing this on wifi so internet is working fine.
Why is it not loading images and how can I make sure it does? I even tried making all images in the html page have absolute paths, but that did not help.
Later Edit: I found out what was causing this. Maybe others will run into this. I had this in the manifest file android:hardwareAccelerated="true". After removing it the content inside all the webviews is loading smoothly.
Second later edit: It is terrible, I get the initial page load now, but forms are not submitting and after some going back and forward to the webview, new images do not load anymore. Is it a memory problem? How do I make it start fresh every time?
WebView wv = (WebView) findViewById(R.id.webview);
wv.getSettings().setBuiltInZoomControls(false);
wv.getSettings().setJavaScriptEnabled(true);
wv.setWebViewClient(new WebViewClient());
wv.loadUrl(filepath);
I want to load two html pages into two different webviews in android.The first html only going to display. The second html should act as background. The script used in second html page need to run, but it won't display to the user. Let me know this is possible in android..
Thanks
Yes dude it is possible
Add a WebView and set it visibility to View.GONE
Like
WebView webView2=new WebView(this);
webView2.setVisibility(View.GONE);
then
webView2.loadUrl("javascript:MyJSFunction(..)
I am working on the Google's open source Android Browser, i am working for a requirement, where i need to show some content into a new webview like a popup dialog. I shall pass some HTML data to the Webiview. I am having some JS within HTML content but the JScript is running on the main page not on the custom webview i created. Please show some way out for it.
Any JScript can be run on the webview, provided we have a script tag embedded in the HTML content rendered on custom webiew created.
Cheers
I'm currently doing a application (project) on android. I would like to know how to create my own buttons in webview, or creating a tab bar in webview. Also, I would want to retrieve certain contents from a website (or rather, from livejournal, to be specifc), like, I do not want the buttons that are in livejournal itself, I just want certain contents, maybe like some live journal posts. Is there any way I could do this?
Thank you so much in advance!
Instead of putting tabs in the WebView you should put the WebView in Tabs. As for pulling information from LiveJournal there are two possibilites. They either have a public api that you can access to get the data you want and use that to populate your app or they don't. If they don't your only recourse would be to pull in the raw html and try to parse it. At that point you might was well just use the webpage as is.