Android app: Salesforce.com “Voice Notes” (part 1)
Recently, we’ve been working on some mobile apps internally at Mavens, mostly on iOS, but the subject of Android development was intriguing to me, especially given my background in Java. So, last week I started doing some research on the subject and found that there were a few different approaches to writing Android apps that could connect to Salesforce.com:
- Adobe Air 2.5 – Run Flash apps on Android (WARNING: this is very much ALPHA software)
- salesforceandroid – Leverages ksoap2 (great work)
- sfdc-wsc (thanks Peter @pmorelli)
- Android + GAE + OAuth + Salesforce – Courtesy of Jeff Douglas
After testing Adobe Air’s 2.5 runtime with native Android support, I realized Flash on Android is simply too unstable (and slow) in its current state. I dug pretty deep into the salesforceandroid project and found it to be a tad exhausting when working with rather complex Soap calls. I tweeted relative to this exhaustion and Peter Morelli @pmorelli reminded me that his colleague at Salesforce.com, Manoj Cheenath had developed a fantastic web service connector called sfdc-wsc. I immediately went to work determining whether sfdc-wsc was a viable option for Android development (spoiler: it’s a more than viable option, as you’ll see below).
One thing was of particular interest though (and cost me a far bit of time unfortunately): Android does not have native support for the javax.* packages, so I had to repackage A LOT of code to get it running on an Android device. Lucky for you, the tough work has been done and the repackaged classes are part of the source code for this example!
I’m going to assume you understand how to create a new Android project in Eclipse. Here’s what you’ll need (and read the docs @ developer.android.com):
VoiceNotes is an Android application that displays a ListView of Accounts, allows the user to select an Account and record his/her voice note to send it up to Salesforce.com as an attachment. Currently, the application captures audio in the Android native format which is a 3GPP wrapper around an AMR audio stream. If you’re on a desktop, Quicktime can play these files.
*VoiceNotes is meant to be an EXAMPLE of the capabilities of sfdc-wsc and Android. It contains examples of logging into Salesforce, querying for records, and making a create call. I left the error handling extremely lax, this is not a production-ready app*
To access the project, please visit http://code.google.com/p/voicenotes/. To get right to the good stuff by installing the application: simply navigate to the /bin folder and download VoiceNotes.apk, which can be installed directly onto your Android device either via the phone’s storage device or via the command line (How to install APK files on your Google Android phone)
So, have a look around at the source while I regroup and get some code examples together. Enjoy!