Documentation > Android

Advanced Topics

Changing account credentials

If you’d not like to insert your account credentials in your app’s AndroidManifest.xml, or would like to change your account ID programmatically, you need to create a custom Application class (if you don’t have one already) with the following content:


public class MyApplication extends Application {
    public void onCreate() {
        CleverTapAPI.changeCredentials("Your account ID here", "Your account token here");
        ActivityLifecycleCallback.register(this); // Must be called before super.onCreate()
copy Copied

If you’ve just created this subclass of Application, update your AndroidManifest.xml to specify your subclass:

copy Copied

Manually updating user location

When permitted, the CleverTap SDK automatically collects and sets the device location. The application is responsible for requesting the user’s permission to use location. If this permission is granted, location is accessible to CleverTap.

On Android, location is provided to the application via the Android Location API. The Android Location API provides two options:


Unless your application is dependent on extremely accurate location data, we recommend selecting the Coarse_Location option since it has better battery performance characteristics. The accuracy of course location is roughly one city block.

The location is updated in CleverTap each time the application is launched and each time the user performs an action in the App (or every 20 minutes if there is no activity in the App).

For more frequent location updates, the App can pass the location to the SDK using updateLocation:

clevertap = CleverTapAPI.getInstance(getApplicationContext());
clevertap.updateLocation(location); //android.location.Location