The Android SDK uses WorkManager to send cached tracking requests in the background.
You can provide custom WorkManager constraints if your app should only send requests under specific conditions, such as when a network connection is available or the battery is not low.
How scheduling works
The configured request interval defines a minimum interval. Actual execution timing is controlled by Android and may happen later depending on system conditions.
The minimum supported interval is 15 minutes.
Requests can be delayed by battery optimization, Doze mode, or other background execution limits.
WorkManager is designed for reliable execution, not exact timing.
Example
class SampleApplication : Application() {
override fun onCreate() {
super.onCreate()
val constraints = Constraints.Builder()
.setRequiresBatteryNotLow(true)
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
val configuration = WebtrekkConfiguration.Builder(
trackIds = listOf("11111111111111111"),
trackDomain = "https://your-trackdomain.com"
)
.workManagerConstraints(constraints)
.build()
Webtrekk.getInstance().init(this, configuration)
}
}public class SampleApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Constraints constraints = new Constraints.Builder()
.setRequiresBatteryNotLow(true)
.setRequiredNetworkType(NetworkType.CONNECTED)
.build();
WebtrekkConfiguration configuration = new WebtrekkConfiguration.Builder(
Arrays.asList("11111111111111111"),
"https://your-trackdomain.com"
)
.workManagerConstraints(constraints)
.build();
Webtrekk.getInstance().init(this, configuration);
}
}When to customize constraints
Use custom constraints when tracking requests should only be sent under specific runtime conditions.
Keep the default SDK constraints if the standard behavior is sufficient for your app.
Related: Configure Global Tracking, Send Tracking Data in Batches