Java Use our Java library in your Android level 8+ or JRE 1.5+ application to track events directly from your customers’ devices. This library using an asynchronous processing queue to make Event tracking a non-blocking affair. This document should give you a quick run-through of how you might go about tracking user sessions.

  1. Download the latest version of the Katana Java library from:
  2. Add the JAR to your classpath and import com.ninjametrics.kapi.KApi.
  3. Initialize a fresh tracking object in your source code: KApi myKApi = new KApi(yourClientId, yourAppId, yourAppPassword);
  4. Register an Account Id for later use:
final GregorianCalendar aTestDob = new GregorianCalendar(1983, 11, 20); // December 20 1983
myKApi.loadAccountCreate(new Date(), "", "Free", "en-US", "US", "M", aTestDob.getTime(), (float) 20.78, "mobile");
This equates to saying that an American male born on Dec 20, 1983 had his account created just now (the new Date() call), with 20.78 in currency, using the “mobile” platform.
  1. Register a Character Id (if you application uses the concept of characters):
myKApi.loadCharacterCreate(new Date(), "wizard", "", "magician", "healer", "T", "fish", "that one guy", 0);
A new character registration happened just now for a character named “that one guy” identified by the string “wizard”.
  1. Log a Login:
myKApi.logLogin(new Date(), "", "wizard", 0, "android", 0);
A login by account “” with his character “wizard” occurred, at the method calling time, using the “android” platform.
  1. Log a Logout:
myKApi.logLogout(new Date(), "", "wizard", 0, "android", 0);
A corresponding logout occurred at the logger method invocation time.

Hopefully that wasn’t too bad?

For a real-ish example Eclipse project, please see our kapi-android-test project: If you are using our library in your Android project, do not forget to allow the Katana API library access to the Katana data-service: <uses-permission android:name="android.permission.INTERNET" />.

Note: that any Account Id or Character Id you want to reference must first be initialized; the initialization only has to happen once over the lifetime of any Id. Please see the javadoc help in your IDE’s code completion for accepted parameter values. The numeric values for theClientId and theAppId can be obtained from the account management panel, or ask your account manager for help.