Edit in GitHubLog an issue

Lifecycle

Sessions contain information about the app's current lifecycle, such as the device information, the application install or upgrade information, the session start and pause times, the number of application launches, and additional context data that is provided by the developer through the LifecycleStart API. Session data is persisted, so it is available across application launches.

Add Lifecycle to your app

Import the library:

Copied to your clipboard
import com.adobe.marketing.mobile.*;

Register Lifecycle with Mobile Core and add appropriate Start/Pause calls

  1. Register the Lifecycle extension:
Copied to your clipboard
public class TargetApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
try {
Lifecycle.registerExtension();
// register other extensions
MobileCore.start(new AdobeCallback () {
@Override
public void call(Object o) {
MobileCore.configureWithAppID("yourAppId");
}
});
} catch (Exception e) {
//Log the exception
}
}
}
  1. In the onResume function, start the lifecycle data collection:
Copied to your clipboard
@Override
public void onResume() {
MobileCore.setApplication(getApplication());
MobileCore.lifecycleStart(null);
}

Setting the application is only necessary on activities that are entry points for your application. However, setting the application on each Activity has no negative impact and ensures that the SDK always has the necessary reference to your application. We recommend that you call setApplicationin each of your activities.

  1. In the onPause function, pause the lifecycle data collection:
Copied to your clipboard
@Override
public void onPause() {
MobileCore.lifecyclePause();
}

To ensure accurate session and crash reporting, this call must be added to every activity.

Lifecycle metrics

Please refer to the Metrics documentation to view the full list of lifecycle metrics.

Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.