Android Demo App
Sample Application for Pulse Insights SDK Integration
Overview
This sample Android application demonstrates the integration of the Pulse Insights SDK. It includes utility classes for simplified SDK configuration, view mapping, and runtime behavior. The application sets up lifecycle callbacks to dynamically manage SDK functionality and trigger surveys based on configurable rules.
Features
Pulse Insights SDK initialization via Maven dependency.
Configurable view mapping for analytics and survey triggers.
Lifecycle management for activities and fragments.
Survey frequency control with debouncing.
Prerequisites
Android Studio version [X.X] or later.
Minimum Android SDK level [XX].
An Account key for Pulse Insights SDK.
Setup Instructions
1. Add Pulse Insights SDK to Your Project
Open your app's
settings.gradle.kts
file and add the Pulse Insights SDK dependency from the Maven repository:Alternatively the dependency may be defined in the application or project build.gradle
In this sample application, the maven repository is resolved in settings.gradle.kts
declare dependency in build.gradle.kts
Add the following elements to AndroidManifest.xml Permissions for sensors
If targeting Android api version 28 and above the following is required to load our httpcore
3. Add Your Account Identifier
Replace account_id
with your Pulse Insights Account ID in the MyApp.kt
file:
4. Configure View Mappings
Add your custom view mappings in res/raw/view_mappings.json
:
5. Build and Run the Application
Open the project in Android Studio.
Connect your device or start an emulator.
Build and run the project to explore the integrated Pulse Insights features.
Project Structure
1. MyApp.kt
MyApp.kt
Initializes the Pulse Insights SDK with an Account key and custom configurations.
Registers lifecycle callbacks for activity and fragment tracking.
Loads view mappings during application startup.
2. PulseInsightsLifecycleCallback.kt
PulseInsightsLifecycleCallback.kt
Handles activity and fragment lifecycle events to set context and trigger surveys dynamically.
Ensures surveys are debounced to prevent frequent triggers.
3. ViewMappingManager.kt
ViewMappingManager.kt
Manages view mappings for activities and fragments.
Loads mappings from a JSON configuration file or defaults.
Retrieves configuration details like survey rules and analytics names.
4. PulseInsightsManager.kt
PulseInsightsManager.kt
Encapsulates SDK initialization and interaction logic.
The PulseInsights SDK API is directly accessible from the PulseInsights Instance, The manager provides a potential implementation for more concise management of survey concepts
Provides methods to set context and trigger surveys programmatically.
5. ViewConfig.kt
ViewConfig.kt
Defines the structure for view configurations, including:
analyticsName
: Analytics identifier for the view.shouldTriggerSurvey
: Whether the survey should trigger for this view.surveyFrequency
: Frequency of survey triggers.
Was this helpful?