Capture specific screens of an Android app
You can configure the Tealeaf library to pause and resume to capture only specific screens of your Android app.
Method A: Edit the configuration file
The preferred method is to edit the TealeafLayoutConfig.json file directly.
By default, you have the following defaults, which capture all screens, events, and gestures, but no screenshots:
{
"AutoLayout": {
"GlobalScreenSettings": {
"ScreenChange": true,
"DisplayName": "",
"CaptureLayoutDelay": 0,
"ScreenShot": false,
"NumberOfWebViews": 0,
"CaptureUserEvents": true,
"CaptureScreenVisits": true,
"CaptureLayoutOn": 2,
"CaptureScreenshotOn": 0
}
}
}
To pause the library, use the CaptureUserEvents
setting and set it to false
to indicate that you want to pause the library and no longer capture information on a screen.
Note:
When you pause the library, it only pauses the capture of user events.
- If you do not want to capture screens, set the
ScreenChange
setting tofalse
.- If you do not want to capture screen visits, set the
CaptureScreenVisits
setting tofalse
.
To resume the library, set the CaptureUserEvents
settings to true
.
The following example code snippet shows how to capture all data except for user events on "FirstActivity" which is the first screen, and then capture user events on "SecondActivity," which is the second screen.
{
"AutoLayout": {
"GlobalScreenSettings": {
"ScreenChange": true,
"DisplayName": "",
"CaptureLayoutDelay": 0,
"ScreenShot": false,
"NumberOfWebViews": 0,
"CaptureUserEvents": true,
"CaptureScreenVisits": true,
"CaptureLayoutOn": 2,
"CaptureScreenshotOn": 0
},
"FirstActivity": {
"ScreenChange": false,
"DisplayName": "First Screen",
"CaptureLayoutDelay": 0,
"ScreenShot": false,
"NumberOfWebViews": 0,
"CaptureUserEvents": false,
"CaptureScreenVisits": false,
"CaptureLayoutOn": 0,
"CaptureScreenshotOn": 0
},
"SecondActivity": {
"ScreenChange": true,
"DisplayName": "Second Screen",
"CaptureLayoutDelay": 0,
"ScreenShot": false,
"NumberOfWebViews": 0,
"CaptureUserEvents": true,
"CaptureScreenVisits": true,
"CaptureLayoutOn": 2,
"CaptureScreenshotOn": 0
}
},
"AppendMapIds": {}
}
You can also disable capturing all data except for specific screens, as shown in the following example.
{
"AutoLayout": {
"GlobalScreenSettings": {
"ScreenChange": true,
"DisplayName": "",
"CaptureLayoutDelay": 0,
"ScreenShot": false,
"NumberOfWebViews": 0,
"CaptureUserEvents": true,
"CaptureScreenVisits": true,
"CaptureLayoutOn": 2,
"CaptureScreenshotOn": 0
},
"FirstActivity": {
"ScreenChange": false,
"DisplayName": "First Screen",
"CaptureLayoutDelay": 0,
"ScreenShot": false,
"NumberOfWebViews": 0,
"CaptureUserEvents": false,
"CaptureScreenVisits": false,
"CaptureLayoutOn": 0,
"CaptureScreenshotOn": 0
},
"SecondActivity": {
"ScreenChange": true,
"DisplayName": "Second Screen",
"CaptureLayoutDelay": 0,
"ScreenShot": false,
"NumberOfWebViews": 0,
"CaptureUserEvents": true,
"CaptureScreenVisits": true,
"CaptureLayoutOn": 2,
"CaptureScreenshotOn": 0
}
},
"AppendMapIds": {}
}
Method B: Call the configuration file programmatically
Use the GlobalScreenSettings
configuration in the TealeafLayoutConfig.json file to set values for all view controllers. Then you call the TealeafLayoutConfig.json configurations programmatically from the screen where you want to apply the settings.
To pause the Tealeaf SDK from capturing specific screens, go to the screen where you want to start pausing the capture and call TealeafLayoutConfig.json programmatically by implementing onStart
and onResume
methods, which are always called when an activity is displayed.
@Override
protected
void onResume() {
Tealeaf.pauseTealeaf();
super.onResume();
}
@Override
protected
void onStart() {
Tealeaf.pauseTealeaf();
super.onStart();
}
override fun onResume() {
Tealeaf.pauseTealeaf()
super.onResume()
}
override fun onStart() {
Tealeaf.pauseTealeaf()
super.onStart()
}
Next, go to the screen where you want to start resuming the library and implement the onPause
method, which is always called when an activity is displayed.
@Override
protected
void onPause() {
Tealeaf.resumeTealeaf(true);
super.onPause();
}
override fun onPause() {
Tealeaf.resumeTealeaf(true)
super.onPause()
}
Updated 4 months ago