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.

    • 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.

      • 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.