Replicate html state in a android native way - android

Let's say I have an HTML page which has CSS bound, all parsed from JSON data; is there a way to reproduce exactly ( with responsivity as well ) the same visualization in an android application with no webview ?
My goal is to have a html product that I can see also on an application, but with native elements.
EDIT
maybe this semplifies the situation: how to share HTML between mobile and web?

textview.setText(Html.fromHtml(HTML_STRING));

Related

Android Webview and iOS UIWebview with same html but difference when displayed

We are developing app for Android and iOS for displaying data from server via API (Data is html). But when set data for webview to be displayed, on Android and iOS has difference.
Suppose web has 3 responses with 3 html(with difference html, css (font size, font name)). But on iOS, font size is same for 3 html, on Android, its has difference between 3 html. I have saved html content to file and open by chrome on windows and iOS. The result on Windows like Android and on Mac like iOS.
I dont know what but I think that has a difference between apples's OS with other OSs.
Anyone know why? Please explain me. Many thanks.
Sorry I can't post html contents to here.

On a mobile device, can I extract data from html using a WebView?

My app parses PC html pages and renders them based on native UI components. Currently I'm working on Android, and use Jsoup to extract data from html.
But now I wish to port my app to iOS, WindowsPhone and other platforms.
So I came to this idea, parsing html with the specified platform's WebView. I googled the use case but find nothing.
I wanna try to implement it as below,
download html, load it into a WebView.
inject zepto.js and my own parse.js into the WebView to traverse DOM and find the data I need.
pass the parsed data to native method to render the native view.
The key issue is how can I prevent WebView to render the raw html to improve performance. I wish WebView to parse DOM and run javascript silently, ignore all CSS, do not paint at all (GUI-Less).
How can I achieve this?
Or is it worthy to parse html using WebView instead of Jsoup?
It is not possible to prevent a WebView from rendering Html. A WebView is a View, it has no GUI-less mode.
To ignore css just don't provide a base url, then it won't find the css files (inline will still be there though).
For what you want to do a WebView is not the correct tool.

Check for input in webview

I have an app that has a web-view which has a basic web-form that has a few fields and a submit button. I would like to figure out in my app if the form has any input in any of the fields. I cannot change the form from the server side, and I can't be certain much about the fields (ids / names in the html).
In iOS we accomplish this with an interesting process of pulling all the html out when loading the form, and comparing it to the html at any given point, if they don't match, the user must have entered something into a field. I believe we were able to get the html by injecting and running some javascript into the web-view. I'm not sure exactly how to approach the problem on android, or if android has any better tools to get whether a form has been edited.
Anybody have any ideas / pseudo-code how I can tell if a form has had input in any of the fields in a webview in android?
Unfortunately, there are no special form-related tools in Android WebView either. You can use the same approach as you have described for iOS.
A couple of links to get you started:
Read HTML content of webview widgets
Android Web-View : Inject local Javascript file to Remote Webpage

Where should I place this library in my android app?

I just downloaded this library ( http://mathscribe.com/author/jqmath.html ) to display equations. Now I have my equation in an html document. So far so good. My question is:
Can I just load that html document in a textview in my android app?
If so, where do I have to place those the html document and the jquery library in eclipse?
this tut might be useful
http://www.mobiledevelopersolutions.com/home/start/included-demo-apps
and you may have a similar problem so consider the following
Help using JQuery in Android WebView
You can display HTML content into a WebView control in your Android app.
You can place the html document into the app assets.

xml parsing with no browser use

I have read the example for Rss Parsing from the ibm site.(http://www.ibm.com/developerworks/opensource/library/x-android/).
In this example,the rss are shown in a listview and then,if you press one announcement you can see it in the web browser of the device.How could i see them in the app,with no use of the device browser?
Thanks a lot
Create a layout with a WebView then load the URL from each "announcement" using WebView.loadUrl.
I'm a little confused but you seem to have answered your own question.
You say you don't want to use the web browser on the device but the example in your question doesn't use the browser. It does exactly what you're asking for.
The idea is that you download the html from the website and then use the parser to break it up into separate "announcements" and store them in list view items in your program.
I have done a bit of this type of thing myself in android. I used jsoup java library, which makes breaking the html into the bits you want to display really easy.
If you want some more help I can give you an example of an app I made that pulls movie times from google.com/movies as an example. here are links to the classes where I did the html download and parse:
ScreenScraper.java
HtmlParser.java

Categories

Resources