Android > Advanced


Batch Sample Apps

If you want to see a proper integration of the Batch SDK and to test any of its functionalities, you can take a look at our sample apps.

Download the sample app on GitHub

You will need an up-to-date SDK and Android Studio installation in order to properly utilize the sample.

Eclipse SDK integration

Note: Eclipse is not supported anymore. These instructions remain for legacy SDKs

Step 1. Download the SDK: Download page.

Step 2. Extract the Eclipse project from the SDK zip.

Step 3. Import it into Eclipse.

Import SDK

Step 4. Add Batch as a dependency of your app.

Add Dependency

You can now proceed with the integration of the SDK.

Proguard rules

If using an old version of the SDK (<1.10.2), or using eclipse, you might need to add Batch's proguard exclusions yourself:

-keep class com.batch.** {
-keep class** {
-keep class** {
-keep class** {



Custom push implementation

If you have your own implementation of GCM push you may have conflicts with Batch Push. GCM broadcasts the push intent to all broadcast receivers so if you send a push via Batch, your own broadcast receiver will also catch it.

To avoid conflict, we provide a helper to detect if a push will be handled by Batch or not, here's how you should implement your own push receiver:

public void onReceive(Context context, Intent intent)
    if( Batch.Push.isBatchPush(intent) )

    // Your push implementation

Now you are ready to enable Batch Push in your app.

Migrating from BatchUserProfile

If you've previously used BatchUserProfile, you can easily use Batch User: you will still be able to set a custom region, language or identifier with the new API.

The main difference between Batch User and BatchUserProfile is that you'll now be required to use an editor object in order to make changes, and then save them. This transactional behaviour brings additional thread-safety and better performance.

That way, what used to be:

BatchUserProfile userProfile = Batch.getUserProfile();
if( userProfile != null )   
    // Use the user profile to set custom language and data 
    userProfile.setLanguage("en"); // Language must be 2 chars, lowercase, ISO 639 formatted
    userProfile.setRegion("US"); // Region must be 2 chars, uppercase, ISO 3166 formatted

Will become this:

    .setLanguage("en") // Language must be 2 chars, lowercase, ISO 639 formatted
    .setRegion("US") // Region must be 2 chars, uppercase, ISO 3166 formatted
    .save(); // Don't forget to save the changes!

BatchUserProfile is now deprecated, but will continue to work. We still suggest you migrate in the near future, so you can take advantage of the new capabilities.