Constant Contact Labs Developer Blog

  • An Android “coupon tracking” app using QR Codes Posted Friday, October 1, 2010 Eric Lubin 2 Comments

    I recently decided to learn Android programming and of course I wanted to use the Constant Contact Web Services, but I also wanted to program against some other features of my phone (that’s why I bought it in the first place!).  I was trying to think a little “outside the box” and still have a useful application.  I thought about using maps, photos, or GPS, but ultimately decided that bar code scanning would be fun!  The result is Coupon Tracker for Constant Contact.

    What’s the rap on the app?

    Coupon Tracker for Constant Contact teaches you how to add a QR code to the coupon in an email and lets you track the usage of that coupon.  Download the application and leave feedback below.  The app will create a contact list named for the coupon and add each user to it as a coupon is scanned.

    The ability to add a QR code to an email coupon is not complicated (even my wife can do it), but walking the user through the steps presented a challenge to me as a developer, since I couldn’t automate the process.  The end result was having the application send yourself an email with step-by-step instructions. Perhaps one day, as QR codes become more ubiquitous, we will see them in product, greatly simplifying the steps involved.

    The application basically has four parts.  The Create Coupon part doesn’t use any of our web services.  It simply asks you for the name of the coupon and uses the email intent to prefill an email to yourself.  The email has instructions about inserting an image into the coupon section of a Constant Contact email.  Google charts makes it crazy easy to build a QR code, basically acting as a web service.  This is where I took advantage of Constant Contacts dynamic data to embed the string $SUBSCRIBER.EMAIL$ in the QR code.  When an email is sent, this is automatically converted to the recipients email address.

    Scan Coupon uses the ScanningViaIntent feature of ZXing.  What a great utility these guys created!!!  Once the application receives the data back from the scan, it uses the the web services to check if a contact list exists or creates a new one for this coupon.  It then looks up the user by email address and tries to update the user record with this contact list.  If they are already a member of that contact list, the web services even returns the date/time they were added, so the app can prompt you on screen exactly when the coupon was used!  Great if you want to give away something expensive to a limited set of users (and don’t want them to print the email twice).  After the scan is complete, the application offers the ability to update a small set of the contact’s information.  It uses most of the same screens and code as Create New Contact.

    List Coupons uses the web services to query all of your contact lists, but pulls out only the ones the application created (they start with CT_).  The web services tell the app how many people are in the list, so we display that as well.  The next feature I hope to add is the ability to drill into that list and fetch those users for display, probably with the ability to update each one.

    Finally, Create New Contact is a lite version of the one available with QuickView.  Mostly I added it to have an even number of icons on the home screen, but I figure it might be useful if people leave this app running behind their retail counter.  It uses the web services to create a new user in your account.

    The plot thickens…

    I learned many interesting things through this exercise.  I really like programming for Android and find it similar to AWT programming.  The event notification model was familiar to me and I was able to jump in quickly.  The easiest part was tying into other applications like ZXing to read the QR code and process the result.

    An interesting challenge was orientation… not something I usually have to take into account when programming in Java for the World Wide Web.  Of course I will never be able to try every Android phone on the market, but the emulator helps and a few of my friends helped test orientation changes on different phones, with and without keyboards.  By creating different XML layouts for horizontal and vertical, I could check for vertical in onStart and otherwise, assume horizontal.  This is because there seems to be a few different horizontal states whether the phone itself is horizontal or a slide out keyboard is open.  Although the layouts share reusable components (thanks to the developer layout tricks), I was able to play with the real estate differently adding the nice wave image when I knew it would fit.

    I found the hardest part of Android programming to be understanding the life cycle of the application and how to correctly handle onCreate, onStart, onResume, onPause, onStop, and on etc.  I was relying on the Android Application object and Singleton objects, not realizing that both of them get garbage collected when Android needs memory.  I probably spent most of my programming effort on saving and restoring object states when I was notified that objects were going away.

    What are you thinking about programming?

    Overall, it was a fantastic learning experience.  I’m excited to start working on another app soon. Do you have any ideas for using Constant Contact Web Services with other features of your android phone? Other uses for bar codes? Google Translate?  GPS?  Web Search?  What about the most basic feature - the phone itself?  Please join in the discussion by posting your comments below! 

     
    The opinions expressed here represent those of the author and not those of Constant Contact, Inc. Read Blog Terms
    Next Post Previous Post
     

Comments (2) +comment on this post
 

  • Angel Miller | 2:11 PM October 18, 2010

    I gotta get an android! My business is beginning to use QR code. This would be awesome!

  • vlad | 3:49 AM March 13, 2012

    QR code is a great invention people made. I’m making mobile apps currently and find it really cool to implement QR codes into them. I’m amazed at QR code coupons Snappii app builder allows to create. They are really helpful for small businesses.

Add your comment below

Remember me

Please enter the word you see in the image below:


*  Please be aware that all comments are moderated.

Recent comments

05/16/12 Alex wrote:

Hi Constant Contact,

How can we change the text fields on the second screen of the Join My List app? I’d like to add fields that are important to us and eliminate some of the others we don’t care about and therefore would prefer our subscribers not be asked.

Interested in a particular topic?

If there are specific topics you’d like to see us discuss on our blog or other ideas you’d like to share, please let us know. Click here to contact us.