From b08a5e16e3ecf3a8529101a91fe1d45872b30fc1 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 17 Jul 2017 13:18:37 -0400 Subject: [PATCH 1/2] Update documentation to reference javadocs in CrowdControl.java file. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35fd3eb..188663f 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ To make changes to this project, you must first install the Android Studio http: ### Open Once Android Studio is installed, open the sdk project. Android Studio will prompt you for missing requirements such as google play services repository. Follow the steps it suggests. -Details for using the library are in the JavaDoc for the CrowdControl class, and in the help wiki at http://help.lotame.com/display/HELP/Mobile+SDK%27s +Details for using the library are in the JavaDoc for the [CrowdControl class](src/main/java/com/lotame/android/CrowdControl.java). ## Building Use `./gradlew clean jarRelease` to build a jar file in the build\libs directory. Modify build.gradle to change the output file name. From 08dcb84af9f4dd5f6b3b791c47c386874d3fd784 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 18 Jul 2017 09:52:44 -0400 Subject: [PATCH 2/2] Adding additional documentation to the README file that shows a code example. --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 188663f..15e443d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,70 @@ compile 'com.lotame:cc-android-sdk:2.3.0.2' Alternatively, you can build the jar manually from the code with `./gradlew clean jarRelease`. The jar file will be available in the build\libs directory. Then you can add that jar as a library to another project. -Details for using the library are in the JavaDoc for the CrowdControl class, and in the help wiki at http://help.lotame.com/display/HELP/Mobile+SDK%27s +Incorporate the following general pattern into your app to collect and transmit data to Lotame, replacing CLIENT_ID with the id provided by Lotame: +``` +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import android.app.Activity; +import android.os.Bundle; +import com.lotame.android.CrowdControl; +import com.lotame.android.CrowdControl.Protocol; + +public class SampleActivity extends Activity { + private static final int CLIENT_ID = ; + private static final int TIMEOUT_MILLIS = 5000; + private CrowdControl ccHttp; + private CrowdControl ccHttps; + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + + // 'this' can be passed in as the CrowdControl constructor's first + // argument because this extends android.content.Context. + // Because no protocol is specified, HTTP will be used. + ccHttp = new CrowdControl(this, CLIENT_ID); + + // Instantiating a CrowdControl instance configured for HTTPS + ccHttps = new CrowdControl(this, CLIENT_ID, Protocol.HTTPS); + } + + public void collectAndSendSomethingInteresting() throws IOException + { + // Add data points to collect. This can be called any number of times + ccHttp.add("seg","poweruser"); + + if (ccHttp.isInitialized()) { + // Optional check that the CrowdControl instance has been initialized. + // Transfer data to Lotame servers. This will transfer all data + // provided via add since the last call to bcp(). Use bcpAsync() + // for asynchronous send. + + ccHttp.bcp(); + } + } + + /** + * @return String a JSON representation of the audience info for the current id + */ + public String getAudienceInfo() throws IOException + { + return ccHttp.getAudienceJSON(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); + } + + @Override + protected void onStart() + { + super.onStart(); + ccHttp.startSession(); + } +} +``` +Call startSession() whenever the user initiates a new session by your definition of a session. For every session, the first call to bcp() or bcpAsync() will count as a "Page View" in the DMP stats. + + +Additional details for using the library are in the JavaDoc for the [CrowdControl class](src/main/java/com/lotame/android/CrowdControl.java) ## Maintainers Development Environment Set-up @@ -25,7 +88,6 @@ To make changes to this project, you must first install the Android Studio http: ### Open Once Android Studio is installed, open the sdk project. Android Studio will prompt you for missing requirements such as google play services repository. Follow the steps it suggests. -Details for using the library are in the JavaDoc for the [CrowdControl class](src/main/java/com/lotame/android/CrowdControl.java). ## Building Use `./gradlew clean jarRelease` to build a jar file in the build\libs directory. Modify build.gradle to change the output file name.