5 Minutes to Social Android Apps with Singly

Hi Everybody. My name is Dennis Kubes. I am based in Dallas, Texas. And I am a developer with Singly working on the Android SDK.

In this post I wanted to show just how easy it is to create social Android apps using the new Singly Android SDK (github). This post assumes you know how to create Android projects in Eclipse and how to import existing projects. This guide will be in three steps:

  1. Register with Singly to get API keys
  2. Download the Singly Android SDK from Github
  3. Use the Singly Android SDK in your app

Register with Singly to get API keys

First go to the Singly Login Page and use either your github account or your facebook account to login. Once authenticated you will be taken to the Singly Apps Page. Click the link that says “Default Singly App” under your applications. We will use the default for now. Later your can create your own apps and register that apps with the various services. The default app page will show your client id and client secret. Copy those two keys, we will need then in a bit.

Download the Singly Android SDK from Github

The Singly Android SDK project can be found on Github. The SDK is all open source. You can clone the project to your local system using the following command.

git clone git@github.com:Singly/singly-android.git

In the SDK there are two folders, an sdk folder and an examples folder. You can import each folder as a project into Eclipse using the “Import Existing Projects” menu item. This should import two projects, one called SinglyAndroidSDK that is an Android library project that holds the SDK, and one called SinglyAndroidExamples that holds example applications.

Use the Singly Android SDK in your app

To use the SDK in your app, you first create a SinglyClient class, pasting in your client id and client secret from the default app you created earlier.

SinglyClient api = new SinglyClient(activity, "your_client_id","your_client_secret");

Once you have the SinglyClient you can have your users authenticate to multiple services (i.e. facebook, twitter, foursquare, github, 18 services total) by calling the authenticate method of the SinglyClient and passing in a service name. Your users should only have to authenticate with each service once for you to be able to access data from that service. Singly APIs endpoints are useful whether you have your users authenticate with one or eighteen services.

api.authenticate("facebook", new AuthenticationListener() {

  public void onStart() {

  public void onProgress(int progress) {

  public void onPageLoaded() {

  public void onAuthenticated() {
    // user is authenticated, make some api calls to get data

  public void onError(AuthenticationListener.Errors error) {
    // uh oh, we got an error during authentication

  public void onCancel() {
    // user cancelled the authenication

The authentication process will launch a dialog with a web view that allows the user to authenticate with the service through oauth. You can pass in an AuthenticationListener class to receive callbacks at various stages of the process. For example, once the user has authenticated, the onAuthenticated method will be called.

Using the SinglyClient class you can have your user authenticate to any Service Singly Supports. Once authenticated you can make Singly API call to get data.

api.apiCall("/services/facebook/friends", "GET", null, null, new APICallListener() {

  public void onSuccess(JSONObject jsonObj) {
    // do something with the json returned, show a list of friends names...

  public void onError(String message) {


You can use the apiCall method to call into any Singly endpoint and get your user’s data from any service they have authenticated with. Take a look at the Singly API Explorer to see all the different calls that can be made and data that can be retieved.


And that’s it! That is all it takes to get social data into your Android application. Quick and easy.

If you want to see some examples run, paste your client id and client secret into the MainActivity and ProfilesActivity classes in the example app in the SinglyAndroidExamples project. Then click “run”. The example shows authentication with different services and making Singly API calls.

If you are in the Chicago area on September 29-30 2012, Singly and Braintree are Having a Hackathon. Come and build an Android app using the new Singly Android SDK.

One thought on “5 Minutes to Social Android Apps with Singly

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s