Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

123 lines (68 sloc) 5.486 kb

Android Couchbase Callback

This application provides the fastest way to deploy a CouchApp to an Android device using Couchbase Mobile and Apache Callback (formerly PhoneGap).

Requirements

This project requires the latest version of the Android SDK. If you already have the SDK tools, you can upgrade by running android update sdk, if you don't have them, you can install via this link

Getting Started

These instructions are divided into two sections, the first describes the development mode. In this mode you can continually couchapp push your changes in for test. The second describes distribution mode where you package your application for distribution.

Development

  1. Clone this repository
  2. Create a local.properties pointing to your Android SDK

    sdk.dir=...

  3. Build this application, either using eclipse or command line tools

    ant debug

  4. Install/Launch this application on your device/emulator

    adb install bin/AndroidCouchbaseCallback-debug.apk

    adb shell am start -n com.couchbase.callback/.AndroidCouchbaseCallback

  5. Couchbase Mobile is now running, you should see now see instructions on screen install your CouchApp.

  6. Forward the Couchbase Mobile from the device to your development machine (the Couchbase port is dynamic and is shown on the screen)

    adb forward tcp:8984 tcp:<value displayed on your screen>

  7. From within your CouchApp project directory, run the following command to install your couchapp on the device.

    couchapp push . http://localhost:8984/couchapp

  8. Refresh the list of CouchApps and navigate to your applicaiton

Distribution

  1. Compact your database

    curl -X POST -H "Content-Type: application/json" http://localhost:8984/couchapp/_compact

  2. Copy the database off the device and into this Android application's assets directory:

    adb pull /mnt/sdcard/Android/data/com.couchbase.callback/db/couchapp.couch assets

  3. Repackage your application with the database file included

    ant debug

  4. Reinstall the application to launch the CouchApp

    adb uninstall com.couchbase.callback

    adb install bin/AndroidCouchbaseCallback-debug.apk

    adb shell am start -n com.couchbase.callback/.AndroidCouchbaseCallback

Examples

Android Couchbase Callback now includes a couple of sample applications to help you get started.

Assumptions

A few assumptions are currently made to reduce the number of options that must be configured to get started. Currently these can only be changed by modifying the code.

  • The name of the database can be anything (couchapp is used in the examples above). BUT, the design document must have the same name.

Further Customizations

  • Change the name and package of your application

    Refactor name and package of ExampleAppActivity to suit your needs

  • Provide your own custom splash screen

    Override the getSplashScreenDrawable() method to point to your splash screen image

Frequently Asked Questions

Q: When I start my application the splash screen shows for a long time, then I get the message "Application Error: The connection to the server was unsuccessful." In the background behind this message I now see my application. But when I press OK, the application exits. What is going on?

A: Most likely your application is loading a resource (something like the _chagnes feed) and this causes the PhoneGap container to fail to recognize that the page has loaded. The fix is simple, add a function to your application that listens for the "deviceReady" event and start your work after this event fires. For example:

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    //  start listenting to changes feed here
}

We are still looking for a better approach to this problem.

TODO

  • spoof a call to onPageFinished so that phonegap paints the screen even if a long ajax call happens before onload.

License

Portions under Apache, Erlang, and other licenses.

The overall package is released under the Apache license, 2.0.

Copyright 2011-2012, Couchbase, Inc.

Jump to Line
Something went wrong with that request. Please try again.