Skip to content

Instantly share code, notes, and snippets.

@elevine
Created September 27, 2011 16:00
Show Gist options
  • Select an option

  • Save elevine/1245475 to your computer and use it in GitHub Desktop.

Select an option

Save elevine/1245475 to your computer and use it in GitHub Desktop.
Couchbase Android Test Application
import com.couchbase.android.CouchbaseMobile;
import com.couchbase.android.ICouchbaseDelegate;
import android.app.Activity;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
public class Main extends Activity {
private long start = 0;
private ServiceConnection couchServiceConnection;
private final ICouchbaseDelegate mDelegate = new ICouchbaseDelegate() {
@Override
public void couchbaseStarted(String host, int port) {
long length = (System.currentTimeMillis() - start);
String logMsg = "Couch Started in : " + length;
Toast.makeText(getApplicationContext(), logMsg, Toast.LENGTH_LONG).show();
Log.d("**MainActivity**",logMsg);
}
@Override
public void exit(String error) {}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
start = System.currentTimeMillis();
Toast.makeText(getApplicationContext(), "Starting Couch", Toast.LENGTH_LONG).show();
startCouchbase();
}
public void startCouchbase() {
CouchbaseMobile couch = new CouchbaseMobile(getBaseContext(), mDelegate);
this.couchServiceConnection = couch.startCouchbase();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment