Android Background Foreground

From Engineering Client Portal

Revision as of 00:31, 8 November 2017 by Admin3 (talk | contribs) (Created page with "{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|International}} {{CurrentBreadcrumb}} Category:Digital = Measuring the Android Foreground/Background State = This gui...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Engineering Portal breadcrumbArrow.png Digital breadcrumbArrow.png International breadcrumbArrow.png Android Background Foreground

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 OVERVIEW

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();