joe-ferraro.com
i like to tell computers what to do
Show MenuHide Menu

Android app: Salesforce.com “Voice Notes” (part 1)

August 25, 2010
Android

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:

  1. Adobe Air 2.5 – Run Flash apps on Android (WARNING: this is very much ALPHA software)
  2. salesforceandroid – Leverages ksoap2 (great work)
  3. sfdc-wsc (thanks Peter @pmorelli)
  4. 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):

  1. Eclipse 3.3+
  2. Android Development Tools “ADT” Plugin for Eclipse
  3. Android SDK

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!

You may also like:

  • http://apexsutherland.wordpress.com/ Alex Sutherland

    Awesome stuff, so glad to see Android development for the Force.com platform moving forward!

    The really killer app would be attaching photos from an Android phone to any object, but most especially custom objects. Think you could make that your next initiative? :-)

  • http://blog.jeffdouglas.com Jeff Douglas

    Joe, I took a look at your code this morning and it looks pretty tight. I think this model may change once they release the REST API with OAuth. Then you’ll be able to write it natively in Android.

  • joe

    @Jeff Douglas: Thanks, Jeff. Yep, I agree, this will be a lot easier with the REST API. Hope we get it soon… (Dreamforce maybe?) :)

  • http://www.tgerm.com/ Abhinav

    Interesting stuff !

  • http://www.moelinux.net moe khan

    Joe, this is great work… i have derived a basic chatter client based on your excellent code… it is posted in the android-chatter-client project @ google code