Android Background Foreground: Difference between revisions
From Engineering Client Portal
(Created page with "{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International}} {{CurrentBreadcrumb}} Category:Digital = Measuring the Android Foreground/Background State = This gui...") |
No edit summary |
||
Line 8: | Line 8: | ||
measurement within Nielsen Digital Content Ratings (DCR). | measurement within Nielsen Digital Content Ratings (DCR). | ||
== | == Foreground and Background State Measurement == | ||
Foreground/Background state measurement may be implemented in multiple ways | Foreground/Background state measurement may be implemented in multiple ways | ||
for Android. This includes | for Android. This includes | ||
Line 23: | Line 23: | ||
AndroidManifest solution. | AndroidManifest solution. | ||
== | == Integrating the Utility Class == | ||
There are four main steps to integrating the SdkBgFgDetectionUtility class for use in | There are four main steps to integrating the SdkBgFgDetectionUtility class for use in | ||
handling foreground/background state notification. | handling foreground/background state notification. | ||
Line 48: | Line 48: | ||
Call the method handleSdkLifecyleEvents to let the class start handling | Call the method handleSdkLifecyleEvents to let the class start handling | ||
foreground/background state measurement. | foreground/background state measurement. | ||
<syntaxhighlight = " | <syntaxhighlight = "android"> | ||
sdkUtility.handleSdkLifecycleEvents(); | |||
</syntaxhighlight> | |||
== Sample Application Class Implementation == | |||
Below is an example application class implementation. | |||
<syntaxhighlight = "android"> | |||
package com.nielsen.myapplication; | |||
import android.app.Application; | |||
public class myApplicationClass extends Application { | |||
@Override | |||
public void onCreate() { | |||
super.onCreate(); | |||
SdkBgFgDetectionUtility sdkUtility = new SdkBgFgDetectionUtility(this); | |||
sdkUtility.handleSdkLifecycleEvents(); | sdkUtility.handleSdkLifecycleEvents(); | ||
} | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 00:33, 8 November 2017
Measuring the Android Foreground/Background State
This guide shows you how to integrate the SdkBgFgDetectionUtility class which Nielsen has made available for measurement of Android Foreground/Background state. Correct measurement of foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).
Foreground and Background State Measurement
Foreground/Background state measurement may be implemented in multiple ways for Android. This includes
- Enable the Nielsen SDK to measure background/foreground state by making
the relevant update to the AndroidManifest.
- Implement the required methods.
- Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom
Application Class. This document is intended to demonstrate how to integrate the SdkBgFgDetectionUtility class. The SdkBgFgDetectionUtility is compatible with Android 4+. If your Android application does not have an existing Custom Application Class, then foreground/background measurement should be achieved through the use of the AndroidManifest solution.
Integrating the Utility Class
There are four main steps to integrating the SdkBgFgDetectionUtility class for use in handling foreground/background state notification.
Add the Class
First copy and paste the SdkBgFgDetectionUtility.java class into your project.
Link the Class to your Project
You must now open SdkBgFgDetectionUtility class and set the package name header to the package name for your specific application:
//Change package to your project package
package com.nielsen.myapplication;
Instantiate the Utility
Instantiate the SdkBgFgDetectionUtility within the onCreate() method of your app’s inherited Application Class.
SdkBgFgDetectionUtility sdkUtility = new SdkBgFgDetectionUtility(this);
Initialise the Class
Call the method handleSdkLifecyleEvents to let the class start handling foreground/background state measurement.
sdkUtility.handleSdkLifecycleEvents();
Sample Application Class Implementation
Below is an example application class implementation.
package com.nielsen.myapplication;
import android.app.Application;
public class myApplicationClass extends Application {
@Override
public void onCreate() {
super.onCreate();
SdkBgFgDetectionUtility sdkUtility = new SdkBgFgDetectionUtility(this);
sdkUtility.handleSdkLifecycleEvents();
}
}