|Version 35 (modified by 10 years ago) ( diff ),|
Android Developer Guidelines
Table of Contents
We have 3 different Android clients written in Java:
- Japan client
- OpenDataKit Collect
It is also possible now to write applications in Python, which would provide the benefit of being easier for the core developers to maintain & could potentially reuse libraries, like the DAL:
It would also be possible to develop a client using HTML5
Uses REST services to talk to Sahana back-end.
Available in Japanese only.
Only works with the code used for the Japan Deployment.
- Download: https://play.google.com/store/apps/details?id=org.sahanafoundation.sahana
- Code: http://bazaar.launchpad.net/~sahana-eden-jp/sahana-eden/sahanaAndroid/files
- Function Names & Comments are in English.
- Dev docs in Japanese: http://www.sahana.jp/development/sahana-android
- but could be translated if there is interest.
- Japan-customised Sahana: http://bazaar.launchpad.net/~sahana-eden-jp/sahana-eden/iwate/files
- Demo: http://japan.sahanafoundation.org/android_backend/
An Android XForms client
Install yet another SCM tool, HG Mercurial
- defaults will suffice during setup
Get a local copy of ODK collect by checking out from Google Code.
Currently the best version to get is the NCSU branch:
hg clone https://vinbitr-odk-collect.googlecode.com/hg/ vinbitr-odk-collect
- ODK Collect trunk (as of Dec 16th)
- jaxdroid changes essential for Sahana
- Support for selecting Images from Media Library
- Support for Wireless Location fix
There is another version which includes support for SMS Form Submission
- link pending
- Install Java JDK
- Install Android SDK
- Download some platforms using the SDK Manager
- Install ANT, a cross platform Java build automation tool.
- Download and extract Ant (1.8.1 at time of writing): http://ant.apache.org/bindownload.cgi
- Create 'ANT_HOME' environment variable.
- Add '%ANT_HOME%\bin' directory to 'PATH' environment variable (Windows syntax).
- Install Eclipse (tested with 3.6.1)
- Install Android plugin
- Import project into Eclipse (project name should avoid spaces)
- Right-click on folder & 'Build Project'
To deploy you'll need to create a self signed keystore and use the .apk packaging wizard (Right-click on project, menu Android tools, Export Signed Application Package), or use the configured Sahana Eden application downloadable from Android Market, enable accept self signed certificates to work with Sahana Eden demo site.
Follow the Build instructions above.
Can Run or Debug in the Emulator
Right-click on the project & select properties | Android to check the API revision used.
- Base ODK Trunk can run on basic Android 1.5: API 3
- SMS functionality requires Android 1.6: API 4
- Does it fail gracefully on older API? (does compile at least still)
See jaxdroid's branch:
<string name="app_name">Sahana Eden</string> <string name="default_server">https://demo.eden.sahanafoundation.org/eden/xforms</string> <string name="main_menu_details">Magnifying human resources with technology</string> <string name="main_menu_message">Sahana Eden</string>
Can use Curl to submit the XForms to the server to easily be able to step though in Eclipse without needing to have a Public IP reach your PC or use the emulator.
curl --basic -u email@example.com:password -F firstname.lastname@example.org http://127.0.0.1:8000/eden/xforms/submission
XForms sent via SMS are split into Multi-Part messages with a sequence header. This header is currently a custom 5-digit unique identifier for that particular form submission. That sequence information and unique identifier are prepended to the each part of the multi-part SMS transmission by the modified ODK Collect branch's SMS form submission code. It will look something like this:
- (1/3)(12345)<?xml version='1.0' ?><pr_person>...
The unique identifier -- here, 12345 -- is actually significantly more random than that.
These messages are then reassembled by the
tropo() function in
controllers/msg.py which calls
concatSMS(lastMessage, fromaddress). The reason the tropo() controller method calls concatSMS() with each new part of a multi-part message is that the messages may arrive out of order. However, when the concatSMS() method detects that all message parts of that XForms submission have been received, it will stitch those messages together (while removing the prepend), and submit them to parserdooth() as for normal messages.
- ANT samples