Other Android APIs

Adjust the log level

You can control the amount of log messages by Mobile Center that show up in LogCat. Use the MobileCenter.setLogLevel() API to enable additional logging while debugging. The log levels correspond to the ones defined in android.util.Log. By default, it is set it to ASSERT for non-debuggable applications and WARN for debuggable applications. You can set the log level at any time you want.

To have as many log messages as possible, use Log.Verbose.

MobileCenter.setLogLevel(Log.VERBOSE);

Identify installations

The Mobile Center SDK creates a UUID for each device once the app is installed. This identifier remains the same for a device when the app is updated and a new one is generated only when the app is re-installed or the user manually deletes all app data. The following API is useful for debugging purposes.

MobileCenter.getInstallId();

This API is asynchronous, you can read more about that in our Mobile Center Asynchronous APIs guide.

Disable all services at runtime

If you want to disable all Mobile Center services at once, use the setEnabled() API. When disabled, the SDK will not forward any information to Mobile Center.

MobileCenter.setEnabled(false);

To enable all services at once again, use the same API but pass true as a parameter.

MobileCenter.setEnabled(true);

This API is asynchronous, you can read more about that in our Mobile Center Asynchronous APIs guide.

Check if Mobile Center is enabled

You can also check if Mobile Center is enabled or not.

MobileCenter.isEnabled();

This API is asynchronous, you can read more about that in our Mobile Center Asynchronous APIs guide.

Use custom properties

Mobile Center allows you to define custom properties as key value pairs in your app. You may use custom properties for various purposes. For instance, you can use custom properties to segment your users, and then send push notifications to a specific audience.

You can set custom properties by calling the setCustomProperties() API. A valid key for custom property should match regular expression pattern ^[a-zA-Z][a-zA-Z0-9]*$. A custom property's value may be one of the following Java types: String, Number, boolean and Date.

CustomProperties properties = new CustomProperties();
properties.set("color", "blue").set("score", 10);
MobileCenter.setCustomProperties(properties);
Note

If you set the same custom property more than once, previous values will be overwritten by the last one.

You may remove any custom property by calling the clear() API. This will only remove the value of the property for a device. It will not remove the property name from Mobile Center portal.

CustomProperties properties = new CustomProperties();
properties.clear("score");
MobileCenter.setCustomProperties(properties);