Yep, it is definitely possible – all while still offering control of all your device’s interfaces such as cameras, bluetooth, wifi…you name it. You see, the hardware dependent components are supported with an Apache developed framework called Cordova. And while this article focuses on the Android platform, the same App can easily be ported to ios or Amazon Fire, with little or no change. Making it possible to develop your App once for distribution across several different device types.
Here is how to setup the development environment and install an application on an Android device.
Setting Up The Environment
What is Cordova?
This is a group of APIs supporting the development of native Apps without using the language of the device. These APIs provide access to the device’s hardware sensors. And with a few simple steps, you are up and running, developing your unique application.
Install node.js from nodejs.org
This will allow you to run “node” and “npm” from a command line window.
Install a git client from http://git-scm.com/.
This will allow you to invoke “git” from a command line.
Install the Cordova module using npm by entering the following at the command line:
npm install -g cordova
Setup the Eclipse for Android App Development Environment by following the following instructable:
Creating A New Application
Open a cmd windows.
Change directory to the base directory for your workspaces (your choice).
Create new folder with app name (no spaces):
Create app file structure:
cordova create appfiles com.author.mynewapp MyAppTitle
- “appfiles” is the folder to create the app file structure
- “com” is the convention used to start the app filename
- “author” is the developer or company name or initials
- “mynewapp” is the bame of the app
- “MyAppTitle” is the title of the app
Add platform (android or ios)
cordova platform add android
Add plugins as needed (basic required plugins;device,console,file shown here)
Get plugin names from plugins.cordova.io/#/ Then enter the following for each plugin to be added:
cordova plugins add org.apache.cordova.device
cordova plugins add org.apache.cordova.console
cordova plugins add org.apache.cordova.file
In the future, plugins will be delivered using npm. See the instruction at plugins.cordova.io/#/ for more information regarding npm plugin delivery.
Building the Application
Install your USB cable from the PC running eclipse to the Android device.
Select Import from the File menu.
Select the base folder created for the newly created project.
First Select “Clean” from the Project Menu.
Then Click on the “Run” icon to build and launch the new app on your device
Editing The Application
The App starts with the launching of the index.html file located at:
<your base app workspace folder>\iotmobile\appfiles\platforms\android\assets\www
<your base app workspace folder>\iotmobile\appfiles\platforms\android\assets\www\js
There you have it!
A quick reference to setting up the Android Development Environment, creating a blank project, building the App and finally loading running it on your device. Now it’s your turn. What will you create?
I hope you find this information useful…