QUADRANT DATA OVERVIEW

Product Overview

Data Dictionary

Global Data Counts

About Mobile Location Data

 

RESOURCES

Cross Account Bucket Access

A. AWS S3

 

Getting Started with Quadrant Mobile Location Data

A. Create a Database, Table and Partition

B. How To Run Basic Location Data Queries

i. Scale and Trend

ii. Depth

iii. Accuracy

C. How Geohash Works (Coming Soon)

 

All You Need To Know About Data Evaluation

A. Best Practices

B. SDK vs Bidstream Data

C. Data Evaluation using AWS Athena

 

Location Data Algorithms and Queries

A. Geo-fencing Query

B. Footfall Query

C. Nearest POI Model

D. Location Algorithms

 

SDK INTEGRATIONS

Android Integration

iOS Integration

Integrate with Unity3D for Android

Integrate with Unity3D for iOS

 
ASIA PACIFIC DATA ALLIANCE

About The Alliance

The Data

Use Cases & Data Science Algorithms

Access APAC Data Alliance Data with AWS S3

 
MEDIA LIBRARY
FREQUENTLY ASKED QUESTIONS

 

 

 

 

DATA ACQUISITION SDK FOR ANDROID

In this detailed guide, we take you through the steps required to integrate the library with your Android app.


 

Pre-requisites

Android SDK support for the library:

  • minSdkVersion 15

 

Tools required:

  • Android Studio (v3.0 and above)

 

Integrating the library

Sending custom data

Tracking location

 

Integrating the Library

Step1: Create/open your android application in android studio.

integrate library1

 

Step 2: Build your app

integrate library2

integrate library2.2

 

Step 3: Import the library as module to the android application

Click File → New Module → Import .ARR/.JAR Package.

Select the .AAR file from downloads.

integrate library3

 

Add library as a module dependancy for your project.

integrate library3.2

 

Build the project to make sure there are no errors

integrate library3.3

 

Step 4: Add required dependencies

Add the following dependencies required for the library:

implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.code.gson:gson:2.8.2'

 

integrate library4

Build the project again to ensure all dependencies are linked correctly.

Note: If your project already has these dependencies, you don't need to add them again.

integrate library4.2

 

Thats it!

If you try accessing a method from the library in your code, it should work.

    Client.getInstance().startTrackingLocation();

integrate library5

 

Congratulations! You have successfully integrated the library to your android project!

 

Sending Custom Data

Using the following codes, create your custom data or event:

Generic generic = new Generic();
generic.putGenericAttribute("myapp-user","user-x");
generic.putGenericAttribute("myapp-user-count","user-x-01");

// You can add more generic attributes here.

You can then send the created data/event with the following codes:

Client.getInstance().trackGenericData(generic, new Client.ResultCallback() {
    @Override
    public void onSuccess(String result) {
        System.out.println("Successfully pushed generic data");
    }

    @Override
    public void onError(String result) {
        System.out.println("Error occured while pushing generic data");
    }
});

You will be getting either a success or failure via the Client.ResultCallback. Process the response accordingly.

send custom data

 

Thats it! You can now send your custom data/event!

 

Tracking Location

Step 1: Configure location access permissions

The library requires three permissions to run properly. Declare them in your app manifest.xml file.

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

 

tracking location 1

 

The next step is to request location access. This will be called during runtime and the user will be prompted with an alert requesting location access:

 

    protected String[] mPermissions = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION};
    private static final int PERMISSIONS_REQUEST = 5003;

    protected void checkPermissionsAndLaunch() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if(!hasPermissions(this, mPermissions)){
                ActivityCompat.requestPermissions(this, mPermissions, PERMISSIONS_REQUEST);
            }
            else {
                // TODO: start tracking location here
            }
        }
    }

    private static boolean hasPermissions(Activity activity, String... permissions) {
        if (activity != null && permissions != null) {
            for (String permission : permissions) {
                if ((ActivityCompat.checkSelfPermission(activity, permission) != PackageManager.PERMISSION_GRANTED) ||
                        (((ActivityCompat.checkSelfPermission(activity, permission) == PackageManager.PERMISSION_DENIED) && ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)))){
                    return false;
                }
            }
        }
        return true;
    }


    @Override
    public void onRequestPermissionsResult(int requestCode,
                                           String permissions[], int[] grantResults) {
        switch (requestCode) {
            case PERMISSIONS_REQUEST: {
                // If request is cancelled, the result arrays are empty.
                if (grantResults.length > 0
                        && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    // permission was granted, yay! Do the
                    // TODO: start tracking location here
                } else {
                    // permission denied, boo! Disable the
                    // functionality that depends on this permission.
                }
                return;
            }
        }
    }
    
    

 

tracking location 1.2

 

After copying the code, you must import all classes referred. If your IDE is already configured to support auto-import, this step will be done by the IDE itself.

tracking location 1.3

 

Step 2: Initiate the Data acquisition sdk

After adding all the required permissions for accessing location. Initialize the data-acquisition client:

  private void setupDataAcquisitionSDK() {

        try{
            Client.getInstance().setup(MainActivity.this, false, false);
           
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

 

tracking location 2

 

Call the all the methods in onCreate related to the activity. After initializing the DataAcquisitionSDK, you will be able to track location.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setupDataAcquisitionSDK();
        checkPermissionsAndLaunch();
    }

 

Step 3: Start tracking location

Now we have set up the library and all the required permissions are in place.

    private void startTrackingLocation() {

        try {

            Client.getInstance().startTrackingLocation();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

start tracking location 1

 

Replace all occurences of TODO: start tracking location here mentioned in Step 1 with the following:

startTrackingLocation();

start tracking location 1.2

 

Congratulations! You have now configured everything required for location tracking!

run_app_to_track_location

 

If you face any difficulties, do reach out to support@quadrant.io.