Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


This guide walks through the setup of the AMPLIFY Appcelerator Services for Android applications. The AMPLIFY Appcelerator Services SDK gives you access to the Appcelerator Analytics , and Cloud and Performance services. To enable the Appcelerator Test for a project, run the AppceletatorTest utility against either the project or APK file.


The following tutorial demonstrates basic setup and usage of Analytics , and Cloud , and Performance libraries in an Eclipse project. To complete the tutorial, you will need your application key for the Cloud , and Analytics , and Performance services. Download a complete version of the project.


  1. In Eclipse, create a new Android project with a Blank Activity.
  2. Unpack the appcelerator-sdk-android-<VERSION>.zip file.
  3. Copy the  appcelerator-sdk-android-<VERSION>.jar  file to the  libs  folder of your Android project (if you wish to use Maven or Gradle, see "Building the Application" below for setup instructions).
  4. Modify the project's AndroidManifest.xml file to include the ACCESS_NETWORK_STATEACCESS_WIFI_STATE, GET_TASKS, INTERNET, READ_LOGS, and WRITER_EXTERNAL_STORAGE user permissions and declare the  com.appcelerator.aps.AnalyticsService as a Service class, which allows the APS library to send analytic events to the APS servers while the application is in the background: 

    Code Block
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android=""
        android:versionName="1.0" >
        <!-- Add these permissions to enable Analytics, Cloud and PerformanceCloud -->
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
        <uses-permission android:name="android.permission.INTERNET"/>
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <uses-permission android:name="android.permission.GET_TASKS" />
        <uses-permission android:name="android.permission.READ_LOGS"/>
            <!-- Add this service to enable Analytics -->
            <service android:name="com.appcelerator.aps.APSAnalyticsService"
                android:exported="false" />
  5. Add the following import statement to the main Activity of the project: 

    Code Block
    import com.appcelerator.aps.APSServiceManager;
  6. In the main Activity's onCreate()  method, add the following method call to enable the APS services.

    Code Block
    APSServiceManager.getInstance().enable(getApplicationContext(), "APP_KEY");

    The Android application is now ready to make method calls using the APS SDK APIs.


  1. Open the fragment layout XML file (res/layout/fragment_main.xml) in the Graphical Layout editor.
  2. Remove the "Hello World!" label.
  3. Drag a Spinner widget, EditText widget (password text field) and Button widget into the view.

  4. In the file, modify the code to save an instance of the current activity, Spinner and EditText widgets. Modify the application to bind a doClick method to the Button's onClick listener and create an empty function called populateSpinner. You need to also import additional packages. In the following sections, you will add code to these handlers that call the Cloud , and Analytics and Performance services. 

    Code Block
    // Import the following packages
    import android.util.Log;
    import android.widget.ArrayAdapter;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Spinner;
    import java.util.HashMap;
    import org.json.JSONArray;
    import com.appcelerator.aps.APSAnalytics;
    import com.appcelerator.aps.APSCloudException;
    import com.appcelerator.aps.APSPerformance;
    import com.appcelerator.aps.APSResponse;
    import com.appcelerator.aps.APSResponseHandler;
    import com.appcelerator.aps.APSServiceManager;
    import com.appcelerator.aps.APSUsers;
    public class MainActivity extends ActionBarActivity {
        // Handle to current activity
    	private static Activity currentActivity;
        protected void onCreate(Bundle savedInstanceState) {
            // Save the current activity
            currentActivity = this;
            APSServiceManager.getInstance().enable(getApplicationContext(), "APP_KEY");
            if (savedInstanceState == null) {
                        .add(, new PlaceholderFragment())
        public static class PlaceholderFragment extends Fragment {
            // Handle to Spinner and EditText widgets
        	Spinner spinner;
        	EditText textField;
            public PlaceholderFragment() {
            public View onCreateView(LayoutInflater inflater, ViewGroup container,
                    Bundle savedInstanceState) {
                View rootView = inflater.inflate(R.layout.fragment_main, container, false);
                // Bind the Button do the doClick method
                Button button = (Button)rootView.findViewById(;
                button.setOnClickListener(new Button.OnClickListener()
                    public void onClick(View v){
                // Save the Spinner and EditText instances
                spinner = (Spinner)rootView.findViewById(;
                textField = (EditText)rootView.findViewById(;
                // Place holder for the next tutorial steps
                return rootView;
            // Placeholder for next tutorial steps
            public void doClick() {         	
            public void populateSpinner() {



Testing the tutorial sample

Before testing the sample, you need to create user accounts for the application to query. To create Cloud user accounts:

  1. Login to the AMPLIFY Platform.
  2. On the Dashboard tile, select Go to Dashboard.
  3. Select your application from the Projects menu.
  4. In the left navigation bar, click Manage Data.
  5. Click Users, then the Create User button.
  6. In the Username field enter the user's username.
  7. In the Password field enter the new user's password (four-character minimum).
  8. Click Save Changes.

To create a Cloud user account, you only need a username or e-mail address, and a password.

For more information about managing Cloud user accounts, see Managing Organizations.

After you have created a few Cloud user accounts, build the sample and launch it on either a device or emulator.

Once the application launches:

  1. Click on the Picker/Spinner. You should see a list of all the Cloud user accounts you added.
  2. Select a user account from the Picker/Spinner and enter that user's password. Click the Button. In the log output, you should see an info log that login command was successful or not.
  3. Go back to the Dashboard.
  4. In Dashboard, select your application from the Apps menu in the upper-left corner.
  5. In the left navbar, click Performance, then Handled Exceptions. You should see the "Something happened..." exception in the list.In the left navbar, click Search by User. Enter the username of the account that successfully logged in. Click the username. You should see a crash report for the user. 
  6. In the left navbar, select Analytics.
  7. In the Real-Time view, you should see at least one active session.
  8. In the left navbar, click Events. You should see the "sample.feature.login" feature event.


This tutorial only covers a small portion of what the Analytics , and Cloud and Performance services can provide. For more in-depth information about these features, see the following topics: