WorkManager
    • 1 Minute to read
    • Dark
      Light

    WorkManager

    • Dark
      Light

    Article summary

    The Mapp Intelligence Android SDK leverages WorkManager to schedule and send cached tracking data (requests) at periodic intervals, as defined by the Config.requestInterval. WorkManager ensures that these requests are executed, even if your app is terminated. It also helps conserve battery life while improving overall performance.

    You can customize WorkManager constraints based on your specific needs, such as limiting execution to when the device is connected to a network or conserving battery power.

    Example Configuration

    The following example shows how to configure WorkManager constraints within your application:

    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)
         }
    }
    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);
         }
    }


    Was this article helpful?