Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Android apps

Live Connect provides an API for the Google Android mobile technology platform. The Android API enables your apps running on Froyo, Gingerbread, Honeycomb, and Ice Cream Sandwich versions of Android to work with info in Outlook.com, Microsoft OneDrive, and other services that are compatible with Live Connect. Although you can still write code to call the Live Connect Representational State Transfer (REST) API directly, the Android API now makes your coding tasks easier.

Note   If you're working on a mobile app that runs on Windows Phone, this isn't the topic you need. Go to Windows Phone apps.

Before you can start calling the Live Connect APIs, you need a client ID. For instructions, see Configuring your app.

Important  You must specify that your client ID is associated with mobile apps such as those for the Google Android mobile technology platform. (Mobile apps use a different OAuth 2.0 authentication flow.) To do this, in the Live Connect app management site for your client ID, click Application Settings Page (or Edit settings, if you've already created your client ID), click API Settings, click Yes next to Mobile client app, and then click Save.


You can use the Live Connect Android API to target Android platform versions 2.2 and later. Note that the Live Connect Android API requires use of the platform API level corresponding to the platform version that you're targeting, as shown here.

Platform nameVersionAPI level

Jelly Bean



Ice Cream Sandwich






















For info about the correct versions to use for the Java SE Development Kit (JDK), the Android software development kit (SDK), the Eclipse integrated development environment (IDE), and the Android Development Tools (ADT) plugin for Eclipse if you choose to use them, see the Android Developers website.


Referencing the Android API with Java

Before you can reference the Live Connect Android API in an Eclipse Android project, you must download the Live SDK for Android and compile the Live Connect Android API source code. Here's how.

To download the Live SDK for Android and compile the Live Connect Android API source code

You must now compile the downloaded Android API source code.

To compile the Android API source code

You need to compile the Android API source code only once. After you compile it on your computer, you can reference it from multiple Eclipse Android projects on that same computer.

  1. Start Eclipse, if it's not already running.
  2. Click File > Import.
  3. Expand General, click Existing Projects into Workspace, and then click Next.
  4. With the Select root directory option selected, click Browse.
  5. Go to and select the src folder within the downloaded Live SDK for Android, and then click OK.
  6. In the Projects box, select the LiveSdk check box.
  7. With the Copy projects into workspace check box selected, click Finish. Eclipse adds the LiveSdk project to the Package Explorer pane and then compiles the Android API source code in the background.

You can now reference the compiled Android API source code from your Eclipse Android projects.

To reference the compiled Android API source code in an Eclipse Android project

  1. In Eclipse, display the Package Explorer pane, if it's not already visible.
  2. Right-click your project's name, and then click Properties.
  3. In the list of project properties, click Android.
  4. In the Library area, click Add.
  5. Click LiveSdk and then click OK.
  6. Click OK. Eclipse sets a reference to the compiled Android API source code project, and you can now call the Live Connect Android API from your own Android project.
Note  Before you run your project, you must add the Internet permission to your project's manifest, as shown in the following steps. If you don't add the Internet permission, your app may have problems accessing Live Connect web services later.
  1. With your project open, in the Package Explorer pane, open the AndroidManifest.xml file.
  2. In the editor, click the Permissions tab.
  3. Click Add.
  4. Click Uses Permission and then click OK.
  5. In the Name list, click android.permission.INTERNET.
  6. Save the AndroidManifest.xml file.


Code sample

To get you started, here's the basic code that shows how to reference the Android API, invite a user to sign in, and get the signed-in user's permission to get his or her basic profile info.


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" >
        android:text="Results will display here." />


package com.live.dev;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import java.util.Arrays;
import com.microsoft.live.LiveAuthException;
import com.microsoft.live.LiveAuthListener;
import com.microsoft.live.LiveAuthClient;
import com.microsoft.live.LiveConnectSession;
import com.microsoft.live.LiveConnectClient;
import com.microsoft.live.LiveStatus;

public class JavaCodeSample extends Activity implements LiveAuthListener {
    private LiveAuthClient auth;
    private LiveConnectClient client;
    private TextView resultTextView;    
    public void onCreate(Bundle savedInstanceState) {
        this.resultTextView = (TextView)findViewById(R.id.resultTextView);
        this.auth = new LiveAuthClient(this, MyConstants.APP_CLIENT_ID);

    protected void onStart() {
        Iterable<String> scopes = Arrays.asList("wl.signin", "wl.basic");
        this.auth.login(scopes, this);
    public void onAuthComplete(LiveStatus status, LiveConnectSession session, Object userState) {
        if(status == LiveStatus.CONNECTED) {
            this.resultTextView.setText("Signed in.");
            client = new LiveConnectClient(session);
        else {
            this.resultTextView.setText("Not signed in.");
            client = null;

    public void onAuthError(LiveAuthException exception, Object userState) {
        this.resultTextView.setText("Error signing in: " + exception.getMessage());        
        client = null;        

MyConstants.java (where MY CLIENT ID is your app's client ID—for example, 00000000603E7410)

package com.live.dev;

final class MyConstants {
    static final String APP_CLIENT_ID = "MY CLIENT ID";


Next steps

From here, we suggest that you continue your learning with the info in Core concepts, Identity API, Outlook.com API, and OneDrive API.




© 2015 Microsoft