Skip to content

Commit 87346e2

Browse files
authored
Document FragmentTtfrHelper usage
1 parent cedb1f8 commit 87346e2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,23 @@ viewTtiTracker.onScreenIsUsable(activity.componentName, rootContentView)
151151

152152
See the [SampleApp](sampleApp/src/main/java/com/booking/perfsuite/app) for a full working example
153153

154+
#### Collecting TTI/TTFR for `Fragment`-based screens in single-Activity apps
155+
156+
The example above works for `Activity`-based screens, however if you use the "Single-Activity" approach you also need
157+
to enable TTI/TTFR tracking for the Fragments inside you main Activity:
158+
159+
```kotlin
160+
class MyMainActivity : Activity() {
161+
162+
override fun onCreate() {
163+
super.onCreate()
164+
val fragmentHelper = FragmentTtfrHelper(viewTtiTracker)
165+
supportFragmentManager.registerFragmentLifecycleCallbacks(fragmentHelper, true)
166+
}
167+
}
168+
```
169+
Then you can call `viewTtiTracker.onScreenIsUsable(..)` in Fragments the same way as described above.
170+
154171
## Additional documentation
155172
- [Measuring mobile apps performance in production](https://medium.com/booking-com-development/measuring-mobile-apps-performance-in-production-726e7e84072f)
156173
- [App Startup Time documentation by Google](https://developer.android.com/topic/performance/vitals/launch-time)

0 commit comments

Comments
 (0)