The SDK uses WorkManager to schedule and send cached tracking data (requests) at periodic times (Config.requestInterval) in the background. WorkManager guarantees an execution, even if your app is terminated. Another advantage is that the device battery is conserved while improving overall performance.

You can adjust the WorkManager restrictions according to your needs.

Example

class SampleApplication : Application() {
 
     override fun onCreate() {
         super .onCreate()
        
         val constraints = Constraints.Builder()
             .setRequiresBatteryNotLow( true )
             .setRequiredNetworkType(NetworkType.CONNECTED).build()
 
         val webtrekkConfigurations =
             WebtrekkConfiguration.Builder(listOf( "111111111111111" ), "https://your-trackdomain.com" )
                 .workManagerConstraints(constraints = constraints)
                 .build()
 
         Webtrekk.getInstance().init( this , webtrekkConfigurations)
     }
}
CODE
public class SampleApplication extends Application() {
 
     @Override
     public void onCreate(){
         super .onCreate();
         
         Constraints constraints = new Constraints.Builder()
             .setRequiresCharging( true )
             .setRequiresBatteryNotLow( true )
             .setRequiredNetworkType(NetworkType.CONNECTED)
             .build();
     
         List<String> trackIds = new ArrayList<>();
         trackIds.add( "111111111111111" );
 
         WebtrekkConfiguration webtrekkConfiguration = new WebtrekkConfiguration.Builder(trackIds, "https://your-trackdomain.com" )
             .setWorkManagerConstraints(constraints)
             .build();
 
         Webtrekk.getInstance().init( this , webtrekkConfiguration);
     }
}
JAVA