In this section:
Installing Medialets Analytics SDK
| NOTE: This guide assumes Eclipse is your preferred IDE. |
- Register your application with Medialets Muse™
- Go to muse.medialets.com and sign up to create your free account.
- After filling in your name and company details, you will be prompted to create your first app.
- Enter the name of your app as well as some additional info and your app will be assigned a unique App ID. You will use the App ID in your BlackBerry J2ME code.
- After receiving your App ID, you will also be prompted to download the Medialets Analytics SDK.
- Add MedialetsAnalyticsSDK_BlackBerry_X_X.jar to your project

NOTE: Medialets provides two separate builds of its Medialets Analytics SDK. If you are supporting multiple BlackBerry platforms, it is your responsibility to incorporate the appropriate .jar files into your projects or automated build scripts. Please contact Medialets' developer relations staff if you have any questions or need assistance with your build configurations.
If you are targeting 4.2 or 4.3 devices, you should use the .jar file in the MMAnalyticsSDK_BB_4_2 folder of the Medialets zip file for your builds.
If you are targeting 4.5 and above devices, you should use the .jar file in the MMAnalyticsSDK_BB_4_5 folder of the Medialets zip file for your builds.- Copy MedialetsAnalyticsSDK_BlackBerry_X_X.jar file to project
- In Windows Explorer, navigate to the folder that contains your Eclipse project.
- In this folder, create a subfolder entitled libs.
- Copy the MedialetsAnalyticsSDK_BlackBerry_X_X.jar file from the SDK to the libs folder you created in the previous step.
- Refresh your project
- To refresh, right-click on the current project and choose Refresh from the pop-up menu.
- After refreshing your project, the libs folder should be visible in your project.
- Add MedialetsAnalyticsSDK_BlackBerry_X_X.jar to Build Path
- Expand the libs folder.
- Right-click on the file MedialetsAnalyticsSDK_BlackBerry_X_X.jar and choose Build Path > Add to Build Path from the pop-up menu.
- Rebuild your project
- Copy MedialetsAnalyticsSDK_BlackBerry_X_X.jar file to project
- Hooking Up Medialets Analytics SDK To Your Application
There are two options by which your application can interact with the Medialets Analytics SDK.
Option One:
We recommend this option if you have a simple application or want to write a quick test application that incorporates the Medialets Analytics SDK.
In the Medialets Analytics SDK, you will find the source code to MMAnalyticsApplication.java and MMAnalyticsScreen.java, which include superclasses from which you can inherit instead of inheriting directly from BlackBerry's UiApplication classes and MainScreen classes respectively. Please note that if you use these superclasses, you will have to update the package name at the top of each file.
Include the MMAnalyticsApplication class and extend it instead of the BlackBerry UiApplication class. Below are the steps needed to use the built-in classes:
Add the following import statement to each file where you wish to use analytics:
import com.medialets.blackberry.analytics.*;Your class definition should look like the sample below:
class MyApplication extends MMAnalyticsApplication {}MMAnalyticsApplication has all the abilities of the BlackBerry UiApplication class with the added functionality of starting, pausing, resuming and stopping the MMAnalyticsManager instance. To track events using this method you can access the instance member in the following manner:
MMEvent event = new MMEvent("MySampleEvent"); mmAnalyticsMgr.trackEvent(event;
The instance of the MMAnalyticsManager class is mmAnalyticsMgr; you can use this object to access any features you need in MMAnalyticsManager.
In addition, to properly set your application version and Medialets Muse App ID, add the two following methods to your derived class. Note that you need to use the exact method signatures below for the code to work properly:
protected String getAppId() { return “MEDIALYTICS_APP_ID”; } protected String getAppVersion() { return “YOUR_APP_VERSION”; }
Also, the Medialets Analytics SDK does not enable location services. If you wish to enable it, you'll need to override the method useLocation() on MMAnalyticsApplication in order to associate location information with tracked events.
abstract public boolean useLocation() { return boolean };
Option Two:
We recommend this option if you have a complex application where, for instance, your main application class already extends a class that extends UiApplication.
Instead of extending MMAnalyticsApplication use an instance of MMAnalyticsManager. The steps needed to achieve this are below.
Specifically, add the following code to your application class that extends UiApplication:- Declare an instance of MMAnalyticsManager in your UiApplication derived class
- Call the sharedInstance() method of the MMAnalyticsManager instance in your UiApplication derived class' constructor
- Call the start() method of the MMAnalyticsManager instance in your UiApplication derived class' constructor
- Call the resume() method of the MMAnalyticsManager instance in your UiApplication derived class' activate() method
- Call the pause() method of the MMAnalyticsManager instance in your UiApplication derived class' deactivate() method
- Call the stop() method of the MMAnalyticsManager instance in your root MainScreen derived class' onClose() method
- Running on a Device or Simulator
- Now, run your code containing references to the Medialets Analytics SDK either on a BlackBerry device or within the BlackBerry simulator.
- BlackBerry Simulator
- From the File menu for the simulator, choose Load Java Program...
- Navigate to where you extracted the Medialets SDK files and select the MMAnalyticsSDK_BB_api.cod that matches the BlackBerry platform version that your are targeting
- Run and debug your program in your BlackBerry simulator
- BlackBerry Device
- In your IDE, select the project that includes references to the Medialets Analytics SDK, right-click, and select Generate ALX file from the pop-up menu
- Copy the file MMAnalyticsSDK_BB_api.cod from the extracted location of Medialets SDK files to a folder which contains your BlackBerry project .jdp file
- Add a reference to the MMAnalyticsSDK_BB_api.cod file within your generated .alx file by adding an entry for it to the <files> section. The <files> section should already contain a reference to the .cod file for your project. Add a comma after the name of this .cod file and add MMAnalyticsSDK_BB_api.cod
- BlackBerry Simulator
- Now, run your code containing references to the Medialets Analytics SDK either on a BlackBerry device or within the BlackBerry simulator.
| NOTE: The Medialets .cod files are pre-signed for your convenience. You are still responsible for signing the .cod file(s) for your projects. |
Congratulations! You've successfully installed the Medialets Analytics SDK!
Sample Project
In the SDK, you will find sample code, which uses the Medialets Analytics SDK. Within the sample project you will find:
- the MMAnalyticsApplication base class
- a MMAnalyticsSample that inherits from MMAnalyticsApplication
- the MMAnalyticsScreen base class
- a MMAnalyticsSampleScreen that inherits from MMAnalyticsScreen and demonstrates the use of custom events