Class POBAppSessionHandler
-
- All Implemented Interfaces:
-
com.pubmatic.sdk.common.session.POBAppSessionHandling
public final class POBAppSessionHandler implements POBAppSessionHandling
This class handles the application session lifecycle by monitoring the app's foreground and background states. It uses the POBAppStateMonitor to track the application's state and determine session durations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfacePOBAppSessionHandler.POBAppSessionListenerInterface definition for a callback to be invoked when the app session events occur.
-
Constructor Summary
Constructors Constructor Description POBAppSessionHandler(POBAppStateMonitoring appStateMonitor)
-
Method Summary
Modifier and Type Method Description UnitinitiateSession()Initiates the application session. final UnitresetSession()This method resets the timers for the foreground and background states of the application. UnitaddAppSessionListener(POBAppSessionHandler.POBAppSessionListener listener)Adds a listener to the list of app session listeners. UnitremoveAppSessionListener(POBAppSessionHandler.POBAppSessionListener listener)Remove a session callback listener from the list of app session listeners. IntegergetSessionDuration()This method calculates and returns the time elapsed since the application entered the foreground. -
-
Constructor Detail
-
POBAppSessionHandler
POBAppSessionHandler(POBAppStateMonitoring appStateMonitor)
- Parameters:
appStateMonitor- The POBAppStateMonitor instance.
-
-
Method Detail
-
initiateSession
Unit initiateSession()
Initiates the application session. This method sets the listener to track the application's foreground and background states. It determines whether to continue the current session or start a new one based on the time spent in the background.
-
resetSession
final Unit resetSession()
This method resets the timers for the foreground and background states of the application.
-
addAppSessionListener
Unit addAppSessionListener(POBAppSessionHandler.POBAppSessionListener listener)
Adds a listener to the list of app session listeners. The listener will be notified of session events such as session start and reset.
- Parameters:
listener- The listener to be added.
-
removeAppSessionListener
Unit removeAppSessionListener(POBAppSessionHandler.POBAppSessionListener listener)
Remove a session callback listener from the list of app session listeners.
- Parameters:
listener- The listener to be removed.
-
getSessionDuration
Integer getSessionDuration()
This method calculates and returns the time elapsed since the application entered the foreground. Ensure to call this method after the session has started.
- Returns:
The duration of the current session in seconds.
-
-
-
-