In this section:
Installing Medialets Analytics SDK
- 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 Android code.
- After receiving your App ID, you will also be prompted to download the Medialets Analytics SDK.
- Add MedialetsAnalyticsSDK_Android.jar to your project
- Copy MedialetsAnalyticsSDK_Android.jar file to project
- Inside the SDK, you will find MedialetsAnalyticsSDK_Android.jar. Copy this into the libs/ directory of your Android project (or integrate it into your project via your preferred IDE).
- Copy MedialetsAnalyticsSDK_Android.jar file to project
- Updating Your Manifest
- Specifically, you need to add the following two permissions:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" />
- Finally, if you enable location services within the SDK, add the following permission:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
- Specifically, you need to add the following two permissions:
- Hooking Up The Medialets Analytics SDK To Your Activities
There are two options by which your activities 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.
Include either the ManagedActivity or ManagedListActivity classes and extend it instead of the Android Activity class. (If you are using something other than Activity or ListActivity you’ll want to read refer to Option Two.) 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.android.analytics.ManagedActivity;
Your class definition should look like the sample below:
class MyActivity extends ManagedActivity {}
ManagedActivity has all the abilities of the Android Activity 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”); mManager.trackEvent(event);The instance of the MMAnalyticsManager class is mManager; 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 activity, note that you need to use the exact method signatures below for the code to work properly:
abstract public String getAppId() { return “MEDIALYTICS_APP_ID”; } abstract public 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 implement the abstract method useLocation() on the ManagedActivity in order to associate location information with tracked events based on what permissions you requested in your AndroidManifest.xml file, the user's preferences, and the capabilities of the device.
abstract public boolean useLocation() { return boolean };
Option Two:
We recommend this option if you need to have control over when the MMAnalyticsManager starts and stops or if you extend an Activity type not supported by the Medialets Analytics SDK.
Instead of extending ManagedActivity or ManagedListActivity use an instance of MMAnalyticsManager. The steps needed to achieve this are below.
You will need to add a few lines to each of your activities, or to other components (e.g., services) that wish to publish events to the Medialets Analytics SDK.
Specifically, each activity should:- Create an instance of com.medialets.android.analytics.MMAnalyticsManager in the onCreate() method of your activity
- Call the start() method of the MMAnalyticsManager instance in your activity’s onCreate() method
- Call the resume() method of the MMAnalyticsManager instance in your activity's onResume() method
- Call the pause() method of the MMAnalyticsManager instance in your activity's onPause() method
- Call the stop() method of the MMAnalyticsManager instance in your activity's onDestroy() method
In the Medialets Analytics SDK, you will find ManagedActivity and ManagedListActivity, which wraps all of the process in a superclass from which you can inherit instead of inheriting directly from Android's Activity and ListActivity classes respectively. This will simplify your use of the Medialets Analytics SDK, but only works for immediate subclasses of Activity, not of MapActivity, TabActivity, etc.
When you call start() on the MMAnalyticsManager instance, you must provide the App ID you received from the Medialets Muse™. You can optionally provide a version name or number; by default, the Medialets Analytics SDK will use the versionName you have embedded in your AndroidManifest.xml file, if available.
Congratulations! You've successfully installed the Medialets Analytics SDK!
Sample Project
In the SDK, you will find a complete project, called Medialets-HelloAnalytics, which uses the Medialets Analytics SDK. Within the sample project you will find:
- an appropriately-configured AndroidManifest.xml file
- a ManagedActivity base class
- a HelloAnalytics activity that inherits from ManagedActivity and demonstrates the use of trackEvent() method
Comments (4)
May 09, 2011
Anonymous says:
Touchdown! That's a really cool way of ptutnig it!Touchdown! That's a really cool way of ptutnig it!
May 09, 2011
Anonymous says:
C4F7CE <a href="http://rjbgkrjpjktr.com/">rjbgkrjpjktr</a>C4F7CE <a href="http://rjbgkrjpjktr.com/">rjbgkrjpjktr</a>
May 10, 2011
Anonymous says:
vZJXBL , [url=http://iouleixgoylo.com/]iouleixgoylo[/url], [...vZJXBL , [url=http://iouleixgoylo.com/]iouleixgoylo[/url], [link=http://dozvwlfdrbcq.com/]dozvwlfdrbcq[/link], http://nljgpcgqmpuv.com/
May 11, 2011
Anonymous says:
OdNSiR <a href="http://vpjdevhzvsxe.com/">vpjdevhzvsxe</a>OdNSiR <a href="http://vpjdevhzvsxe.com/">vpjdevhzvsxe</a>