AppLift Android SDK

The AppLift SDK is in full compliance with Google's latest policy change regarding ads in Android apps.

Are you interested in monetizing your app with the AppBrain AppLift SDK?

Sign up now!

AppBrain AppLift SDK

AppBrain provides two SDKs for use in your Android apps. The AppBrain AppLift SDK contains all services, including analytics and monetization. The AppBrain Advertiser SDK only includes conversion event tracking and remote settings. If you're unsure which one to choose, take the AppLift SDK. The following table lists the main features of both SDKs.

Overview of the AppBrain Advertiser SDK and AppBrain AppLift SDK

Advertiser SDK
< 100 kb
AppLift SDK
< 150 kb
Best-in-class monetization with the AppBrain interstitial
User friendly banners for app monetization
Effective control over your app with Remote settings
Conversion event tracking for campaign finetuning
Integration time < 20 minutes < 20 minutes
Get it on GitHub Get it on GitHub

The AppBrain AppLift SDK is present in over 30,000 apps and is downloaded onto millions of phones every day.

The main benefits of AppLift are:

  • Integration is easy and takes less than 20 minutes.
  • The SDK is small (<100kb) and is thoroughly tested in the field.
  • You can generate an additional revenue stream, completely independent of already existing revenue models. AppLift can be combined with any other ad network.
  • The only permissions needed are internet permission and access network state.
  • Supports Android version 2.1 and up.

How to get started with the AppBrain SDK

This section explains how to integrate our SDK into your Android app. There are a few steps to getting up and running:

  1. Create an AppBrain developer account to get access to the AppBrain developer dashboard, and register your app for the SDK there.
  2. Download the AppBrain SDK from our AppBrain AppLift GitHub project page.
  3. Integrate the SDK in your app and publish it to the Android Market. Make sure your integration follows our policies.

Please contact us directly at [email protected] if you need any assistance, and we will be happy to help you.

In case you want the AppLift SDK, copy the file appbrain-applift-sdk.jar into the libs/ folder in the app project directory (if this folder doesn't exist yet then create it first). In case you want only the features from the advertiser SDK, copy the file appbrain-advertiser-sdk.jar instead.

Changes to AndroidManifest.xml

The AppBrain SDK needs the permission to access the internet. You probably have these permissions in your app already. Please make sure the following lines are in your AndroidManifest.xml outside of the <application> tag:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Also there are several required activities and services which are needed for the SDK. Please add these lines to your AndroidManifest.xml inside the <application> tag:

<!-- AppBrain SDK -->
<activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" 
    android:name="com.appbrain.AppBrainActivity" />
<service android:name="com.appbrain.AppBrainService" />        
<receiver android:exported="true" android:name="com.appbrain.ReferrerReceiver" >
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

Now your app is ready to use the features of the AppBrain SDK.

Proguard

If your app uses proguard to obfuscate your code before packaging it in your APK, you need to add the following lines to your proguard config file:

-keep public class cmn.Proguard$KeepMembers 
-keep public class * implements cmn.Proguard$KeepMembers
-keepclassmembers class * implements cmn.Proguard$KeepMembers { 
   <methods>; 
}
-keepattributes *Annotation*
-keep class android.webkit.JavascriptInterface
-dontwarn android.webkit.JavascriptInterface
# This is only needed when you don't include the Google Play services:
-dontwarn com.google.android.gms.**

Initializing the AppBrain AppLift SDK

To use AppLift, you need to make sure it is initialized.

You can initialize it by calling AppBrain.init(this) in your Activity or AppBrain.initApp(this) in your Application.

import com.appbrain.AppBrain;

public class ExampleApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        AppBrain.initApp(this);
    }
}

If your app does not use an own Application class (which also needs to be declared in the AndroidManifest), you can also do it in your Activity. Please make sure you call init in all Activity classes where you use the SDK.

import com.appbrain.AppBrain;

public class ExampleActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AppBrain.init(this);
    }
}

Banners

banner example

The AppLift SDK allows you to put industry-standard 320x50 dip banners into your app. This can be done either in XML or programmatically.

In a layout XML file, you can add a banner to your app using the following code:

<com.appbrain.AppBrainBanner 
  android:layout_width="fill_parent" android:layout_height="wrap_content"/>

By default, the banners choose a random design, color, text and button text, and are internationalized to the language that's set on the users' phone. If you want to configure the design, colors, text or button text explicitly, you can do so by adding xmlns:appbrain="http://schemas.android.com/apk/lib/com.appbrain" to an element in your layout XML and then using appbrain:colors, appbrain:design, appbrain:title and appbrain:button values with custom values to lock the settings to particular values. You can see the AppLift SDK Demo app's main.xml file as an example, or for more information refer to the AppBrainBanner javadoc.

If you want to instantiate the banner programmatically, you can use the following piece of code:

    import com.appbrain.AppBrainBanner;

    public void addBanner(ViewGroup parent) {
        AppBrainBanner banner = new AppBrainBanner(getContext());
        parent.addView(banner);
        banner.requestAd();
    }

If you include a banner in layout XML, the requestAd() method is automatically called, but in code you need to call it yourself.

The AppLift SDK Example app contains a "banner playground" where you can experiment with what a banner looks like with different settings:

Admob mediation

Using AppLift banners in mediation solutions

AppLift banners are easy to integrate into either Admob or AdWhirl mediation placements.

Please view the dedicated pages about integration for either Admob mediation, AdWhirl or MoPub integration.

Showing the interstitial

The AppBrain interstitial is an activity to ask users if they are interested to see the AppBrain offerwall, which promotes free apps to your users. Each app a user installs from the offerwall will generate revenue for you.

interstitial example

The interstitial is the main way to generate revenue with the AppLift SDK.

The best moments to show the interstitial are at a natural pause moment in your app, for instance when an important event just has completed, such as sending a photo or finishing a game level, or when leaving the app.

To show the interstitial when the user leaves your activity, you can use this code:

@Override
public void onBackPressed() {
    super.onBackPressed();
    if (isFinishing()) {
        AppBrain.getAds().maybeShowInterstitial(this);
    }
}

If you use the maybeShowInterstitial function, the AppLift SDK automatically makes sure the interstitial is only shown occasionally (by default once every 3 days), which is why the maybe is in the method name. Therefore it's safe to call this method in multiple places without having to do your own rate limiting.

If instead you always want to show the interstitial when the method is called, use:

AppBrain.getAds().showInterstitial(activity);

Offerwall

Offerwall Example

The default interstitial leads to the offerwall. In case you don't want to use the interstitial, you can access the offerwall directly.

The AppBrain SDK can set the OnClickListener of a View for you so that it opens the offerwall directly:

AdService ads = AppBrain.getAds();
Button button = new Button(context);
button.setText(ads.getOfferWallButtonLabel(context));
ads.setOfferWallClickListener(context, button);

A similar method is available for opening the offerwall from a menu item:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    AdService ads = AppBrain.getAds();
    MenuItem item = menu.add(ads.getOfferWallButtonLabel(this))
    ads.setOfferWallMenuItemClickListener(this, item);
    return super.onCreateOptionsMenu(menu);
}

It is also possible to show the offerwall directly via showOfferWall. However for using this method you need to request approval. In our experience, the use of the interstitial gives up to 10x more revenue than other simple integrations using the offerwall directly. If you do feel you have a need to integrate without using the interstitial, please contact us at [email protected] to discuss this.
Using showOfferWall without approval won't generate any revenue.

Remote Settings

The AppBrain SDK will regularly check for updates to "remote settings". These are values you can set in the AppBrain developer dashboard for your app. With these settings, you can control your app remotely without having to launch a new update. The things that can be controlled range from very simple things, like the text of a welcome message, to turning major functionality in your app on or off.

All settings are String key-value pairs. For example to show a customizable welcome message:

// get latest value for welcome_message, defaults to "Hello"
String welcomeMessage = AppBrain.getSettings().get("welcome_message", "Hello");

// show as toast
Toast.makeText(this, welcomeMessage, Toast.LENGTH_LONG).show();

If you run this code, it will show a toast with "Hello". Now you can go to the AppBrain developer dashboard for your app and set the value for welcome_message, e.g., to "Hello from AppBrain". Once the app has fetched the updated settings, it will show this new message instead.

Note: The SDK fetches the settings at most once per day (when init is called), therefore it will use the old value if you have already started the app on this day. If you're testing, you can use "Delete settings" in the Android settings page for your application to force a refresh, or uninstall and reinstall your app.

Conversion event tracking

The AppLift SDK and the smaller AppBrain Advertiser SDK allow you to track "conversion events" in your app. This can be any event you find useful to track, for instance a user signing up for your service, or a completed in-app payment. On the AppBrain developer dashboard you're able to see the number of conversion events in your app per day. Every event can have an integer value you assign to it. The dashboard will show you the sum of the values of the events and the average event value. For an in-app payment you could for instance set the value to the number of cents of that was spent.

The type of event you track is given by a String that you assign. The maximum length of this string is 20 characters.

Example code for tracking an in-app payment (we assume that AppBrain.init() has already been called in the Activity.onCreate()):

public void trackSuccessfulIabPayment(int cents) { 
    AppBrain.getAdvertiserService().sendConversionEvent("iab", cents);
}

Integration with Unity

Apps which are developed with the Unity game development tools can easily integrate with AppBrain AppLift using our AppLift Unity plugin.
This tutorial describes how to integrate AppBrain AppLift into your Unity app.


AppBrain SDK overview and documentation | SDK integration policy | SDK terms | AppLift javadoc