Versions Compared

Key

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

...

  1. Go to the Appcelerator Dashboard and create a new native Android application.
  2. Download the Services SDK and get your Analytics application key.
  3. Unpack the Services SDK ZIP file.
  4. Copy the the appcelerator-sdk-android-<VERSION>.jar  to the  lib  folder folder of your Android project.
  5. Modify the project's  AndroidManifest.xml  file to include the following permissions and to add the APSAnalytics package as a service: 

    Code Block
    titleAndroidManifest.xml
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.appcelerator.sample"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <!-- Add these permissions to enable Analytics -->
        <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"
                     android:maxSdkVersion="18" />
    
        <application>
            <activity>
                ...
            </activity>
     
            <!-- Add this service to enable Analytics -->
            <service android:name="com.appcelerator.aps.APSAnalyticsService"
                android:exported="false" />
    
    
        </application>
    </manifest>
  6. Add the following import statements to the main Activity of the project: 

    Code Block
    titleMainActivity.java
    import com.appcelerator.aps.APSServiceManager;
    import com.appcelerator.aps.APSAnalytics;
  7. In the main Activity's  onCreate()  method, enable the service by calling the APSServiceManager's enable  method.  Pass Pass the method the application context as the first argument and the APS application key as the second argument.  

    Code Block
    public void onCreate() {
        APSServiceManager.getInstance().enable(getApplicationContext(), "APP_KEY");
    } 
    Tip

    To get your APS App key:

    1. Go to the Appcelerator Dashboard.
    2. Select your application from the Apps drop-down menu.
    3. Click the Overview tab.
    4. Click the Services button.
    5. Click Show Key under the Analytics, Performance and Cloud section.

The Android application can now make additional method calls using the  APSAnalytics class.  Before making API calls to the APSAnalytics class, you need to retrieve a shared instance using the getInstance() method.  Make Make APSAnalytics API calls using the shared instance.

...