Integrate the SDK APIs on Android
  • 28 Mar 2025
  • 1 Minute to read
  • Dark
    Light
  • PDF

Integrate the SDK APIs on Android

  • Dark
    Light
  • PDF

Article summary

First, add the ShieldSDK-config Maven dependency to your Android project. This can be found in the SDK/maven/ directory of the App Shielding package.

You can then use the ShieldConfig class with the following methods:

Methods for ShieldConfig class

Method

Description

requestUpdate()

Triggers App Shielding to download a configuration update.

setUpdateCustomId(token)

Sets the X-update-custom-id header for configuration requests. The provided NSData is stored and used for any future request to the server.

setUpdateCallbacks(callback)

Registers a listener that is invoked whenever the app downloads a configuration update. The callback receives a time stamp value that reflects the embedded time stamp from the downloaded configuration.

The following example demonstrates how these methods can be used:

ShieldConfig.requestUpdate();
ShieldConfig.setUpdateCustomId("my-token".getBytes(StandardCharsets.UTF_8));

ShieldConfig.setUpdateCallbacks(new UpdateCallbacks() {
  @Override
  public void configUpdateReceived(String timestamp) {
    // handle callback logic
    ...
  }
});

Always call these methods from a background thread as the app's main thread is reserved for updates of the user interface, as specified by Android.

aBackgroundThread {
  ShieldConfig.requestUpdate();  
  ShieldConfig.setUpdateCallbacks();  
  ShieldConfig.setUpdateCustomId();
 }

You should be aware that the downloaded new configuration is not applied immediately, but only after an application is restarted.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Ozzy, our interactive help assistant