Versions Compared

Key

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

...

  1. Go to the 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 appcelerator-sdk-android-<VERSION>.jar to the  lib 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
    linenumberstrue
    languagexml
    <?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
    languagejava
    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 the method of the application context as the first argument and the APS application key as the second argument.

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

    To get your APS App key:

    1. Go to the 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 and Cloud section.

...

Use the APSAnalytics' sendAppGeoEvent() method method to send real-time geographic data to the Analytics service. Pass the method of an Android Android Location object object.

In the following example, the application uses a default location provider to get location information from the device. The application sends the location data to the Analytics service.

...