Forums Register Login
HtmlUnit for Android
I'm developing an app and I need to retrieve data from html code. In addition, i would like manage the event (for example, click the button and redirect in other page) in html code.
I searched on Google and I've found a beautiful library that meet my needs: HtmlUnit.
The problem is the compatibility with Android SDK: there are conflicts with Android classes and maybe, I must to recompile the source code for Android compatibility.
Are there alternative to HtmlUnit? I don't know how to build this library...Can you help me?

Any help would be most welcome...thank you!

PS: sorry for my poor english!
Welcome to JavaRanch.

The good news is that getting and building HtmlUnit is pretty easy. http://htmlunit.sourceforge.net/gettingLatestCode.html shows how in "Checking out SVN repository" and "Compiling the code" assuming you have Subversion and Maven installed.

The bad news is that HtmlUnit uses Java classes that are not available on Android. These are the AWT, Swing and ImageIO classes that came to my mind; there may be other APIs I'm not thinking of:

On top of that, HtmlUnit uses a bunch of other libraries, some of which may have their own dependencies on these libraries. So, as awesome as HmlUnit is, I think getting it to run on Android may not be an easy task.
Thanks for your reply!
So, I understood. Mmm...is not an easy task.
According to you, are there similar alternative to HtmlUnit? Mainly, I need to get html and simulate a button click...

If this is one specific web page in which you need to simulate one specific action, you might use Android's built-in HttpClient library. It's fairly easy to code up a form submission with that.

If you need more flexibility (several forms, data extraction from the web page, different web pages, etc.) you could run HtmlUnit as part of a Java web app, and have the Android app communicate with it over a REST API. That might be way over-engineered, depending on your requirements.
It's exactly the same and completely different as this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database

This thread has been viewed 3951 times.

All times above are in ranch (not your local) time.
The current ranch time is
Mar 20, 2019 11:07:51.