Can I Get Android Native UI Remotely? Presenting ItsNat Droid
Can I Get Android Native UI Remotely? Presenting ItsNat Droid
Are you looking for native Android APIs and UIs in your hybrid app? ItsNat is doing that and more, bringing competition to PhoneGap.
Join the DZone community and get the full member experience.Join For Free
What is ItsNat Droid?
ItsNat Droid makes possible to make Android client/server applications following the web paradigm but using only native Android APIs and UIs. ItsNat Droid is open source, and yes, it is associated to the ItsNat Web Framework (in fact this framework is extended for Android).
It tries to break the "Amazon shop app dilemma": fully exploit of Android native UI capabilities vs UI flexible maintenance in server without app upgrade (just to change a color) using web tech.
"the most compelling reason to incorporate HTML5 into your mobile applications is to get the ability to update the app without requiring an upgrade on the device user's side. This capability makes it both easier and safer to manage apps -- permitting developers to roll out or draw back updates as needed. In the brave new world of continuous deployment and live testing, that's a huge advantage"
ItsNat Droid breaks the "impossibility" of loading native Android resources (layouts, drawables, animations...) dynamically:
ItsNat Droid makes a big effort to mimic the Android conventions to build Android applications specifically UI but extended and moved to a remote side, where Android resources are delivered, events are received following using a sort of AJAX, behaviour is transported to client as scripts and many actions can be executed in server side including remote UI manipulation. As you can see later, the level of remote UI and behaviour is up to you (from almost fully remote to something remote).
ItsNat Droid is open source Apache v2 licensed.
In spite of ItsNat Droid Client contains the name "ItsNat", it can be used outside ItsNat Server.
ItsNat Droid client has several levels of interoperatibility:
1) Parsing a XML file containing an Android layout, this XML can be read or loaded from any source by you (assets folder is recommended).
Dependent native resources and/or resources in "asset" directory are loaded when specified in layout.
The application is fully local according to UI but organization based on assets provides more flexibility. Folders and file organization in
assets/ folder can be similar to the standard
res/ folder but this is not mandatory.
Take a look to this layout example in
Take a look to references like
@assets: indicates ItsNat Droid must search the required resource into the folder
assets/, as you can see native references to standard
res/ and android O.S. provided resources are possible.
The second example
access to the
test_values_asset.xml file containing a
<resources></resources> XML locating the specified variable
By using a simple API you can download remote native Android layouts from ANY web server and be able to do Single Page Interface with Android layouts.
Take a look to this very simple, raw and ugly example of a SPI application web server agnostic:
There are some other extensions like using the "id" standard attribute as alternative to android:id (valid also).
Take a look to resource references like:
3) Total integration with ItsNat Server.
For instance (layout and layout fragment) in a web server:
You can find resource references like this:
there is no much to explain, the referenced resource is the remote archive
test_values_remote.xml (expected a
<resources></resources> format) and read the variable
Some server side code snippets manipulating layouts:
Do you need Drawables?
Some examples of drawable XML declarations (linked in the previous layout example):
Yes inside XML resources you can reference other remote XML resources like in:
Do you need animations?
Some examples of animations in XML (linked in the previous layout example):
Do you remember the powerful Remote Control capability of ItsNat Web? Yes you can do the same with Android, another Android device can be monitor an Android layout of another device (with permission of course), most of non-web stuff of ItsNat server is supported.
Finally, as you can see ItsNat Droid allows construction of remote Android applications with different levels of remoting, from almost fully remote to some stuff remote. The assets alternative was initially designed to help testing, but it can be used when res/ standard format is too rigid.
ItsNat Droid Client SDK (and server side code in ItsNat Server) is on heavy development, there is no release in spite you can download a demo and play or build from source code using Android Studio (master branch)
The published app demo (apptest) points to the server http://www.innowhere.com/itsnat_dev/ . Android XML layouts are generated using a MIME not recognized by web browsers.
Development happens on the development branch, this is the branch to get the latest:
Android client code is Java 6 compatible and supports Android +4.0.3 devices, developed with Android Studio.
You can play with the "apptest" Android application with many visual tests (also there're a lot of tests in code), no you're not going to find here something pretty, just systematic testing. You must configure the URL of your ItsNat server (when loading this app click the Back button of your device for URL configuration, save your URL and then click on "GO TO TESTS" button). Some examples like "TEST LOCAL X" are local and can run without ItsNat server, the key to understand these tests is by clicking "RELOAD" button you get the same layout but processed dynamically (same files as compiled XMLs but as asset files).
All said before is already done and running like layouts (including tag support) drawables and some work on animations is done, but ambitious new things are pending like be able of download and all types of Android resources and higher level components attached to DOM elements for easier management like components in ItsNat Web.
Downloads: Demo and SDK library
DEMO : the application used to test ItsNat Droid, all features are used here.
ItsNat Library : the library to be includes in your application providing a public and simple API.
Requirement: Android +4.0.3
The source code of the server side (an ItsNat based web application) is here.
Opinions expressed by DZone contributors are their own.