NavigationViewTrackingStrategy - DataDog/dd-sdk-android GitHub Wiki
class NavigationViewTrackingStrategy(@IdResnavigationViewId: Int, trackArguments: Boolean, componentPredicate: ComponentPredicate<NavDestination> = AcceptAllNavDestinations()) : ActivityLifecycleTrackingStrategy, ViewTrackingStrategy, NavController.OnDestinationChangedListener
A ViewTrackingStrategy that will track Fragments within a NavigationHost as RUM Views.
Parameters
navigationViewId | the id of the NavHost view within the hosting Activity. |
trackArguments | whether to track navigation arguments |
componentPredicate | the predicate to keep/discard/rename the tracked NavDestinations |
Constructors
NavigationViewTrackingStrategy
constructor(@IdResnavigationViewId: Int, trackArguments: Boolean, componentPredicate: ComponentPredicate<NavDestination> = AcceptAllNavDestinations())
Parameters
navigationViewId | the id of the NavHost view within the hosting Activity. |
trackArguments | whether to track navigation arguments |
componentPredicate | the predicate to keep/discard/rename the tracked NavDestinations |
Functions
onActivityPaused
open override fun onActivityPaused(activity: Activity)
onActivityStarted
open override fun onActivityStarted(activity: Activity)
onActivityStopped
open override fun onActivityStopped(activity: Activity)
onDestinationChanged
open override fun onDestinationChanged(controller: NavController, destination: NavDestination, arguments: Bundle?)
startTracking
fun startTracking()
Starts tracking on current activity.
This is automatically called when activity starts. If using static navigation setup, with navigation container in XML layout, there's no need to call it manually. However if using dynamic navigation setup where navigation controller is created programmatically, then this function must be called after navigation controller is injected into view hierarchy. Regardless of the usage, the function always relies on view ID provided with the constructor.
If activity is stopped, the function will return immediately without starting tracking.
stopTracking
fun stopTracking()
Stops tracking current activity.
This is automatically called when activity stops. If using static navigation setup, with navigation container in XML layout, there's no need to call it manually. Even with dynamic navigation setup where navigation controller is created programmatically, default behavior should be enough. But the function is here in case tracking needs to be managed outside of the default activity lifecycle. In this case note that it's possible to call startTracking and stopTracking multiple times in succession.
If activity is stopped, the function will return immediately.