Anda di halaman 1dari 29

Your How-to Guide

Integrating LeadBolt with Android Apps

LeadBolt Android SDK

Version: 6.1 Copyright 2013 LeadBolt All rights reserved

Disclaimer This document is provided as-is. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it. This document does not provide you with any legal rights to any intellectual property in any LeadBolt product. You may copy and use this document for your internal, reference purposes. 2013 LeadBolt. All rights reserved. Android is a trademark of the Google Inc. All other logos and trademarks are the property of their respective trademark owners.

App Market places Various app marketplaces apply conditions on app developers that they must comply with, when participating or uploading apps to these marketplaces. Please note, the inclusion of this unified SDK does not transfer that responsibility and it remains the responsibility of the App developer to achieve compliance with any app marketplace conditions. Our SDK includes features and functions to support App developers efforts with marketplace compliance and we strongly recommend including or utilizing those features where possible.

Copyright 2013. LeadBolt. All rights reserved

Page 2 of 29

Table of Contents
WHAT'S NEW IN V6.1 ....................................................................................... 4
DISPLAY/AUDIO AD CACHING (NEW) ........................................................................................ 4 AUTO-SCALING BANNERS (NEW) ............................................................................................. 4 PERFORMANCE & AD LOADING SPEED ENHANCEMENTS .................................................................... 5

ADDING LEADBOLT ADS TO YOUR ANDROID APP ............................................. 6


STARTING AS A LEADBOLT APP PUBLISHER ................................................................................... 6
Step 1: Register for LeadBolt Publisher Portal access ..............................................................6 Step 2: Get the Android SDK ....................................................................................................6

SETTING UP THE ANDROID DEVELOPMENT ENVIRONMENT .............................. 7


GETTING STARTED .............................................................................................................. 7 LINKING IN THE REQUIRED LIBRARY ............................................................................................ 7
Step 1: Modifying Permissions .................................................................................................7 Step 2: Add the LeadBolt static library.....................................................................................8

GET STARTED WITH QUICKSTART ADS ............................................................. 9


ADD REQUIRED PERMISSIONS/RECEIVERS/SERVICES ..................................................................... 9 ADD THE ADDITIONAL APPFIREWORKS PERMISSIONS (HIGHLY RECOMMENDED) ....................................... 9 ADD REQUIRED CODE ........................................................................................................ 10 HANDLING SYSTEM REBOOTS ............................................................................................... 11

WORKING WITH 'APP AD' TEMPLATES ........................................................... 12 ADDING A LEADBOLT 'APP AD' TO YOUR APP CODE ....................................... 13
COMPLETING A SIMPLE INTEGRATION ........................................................................................ 13 ADVANCED INTEGRATION WITH CACHING .................................................................................... 14

MAKING HIGH PERFORMANCE 'APP AD' TEMPLATES ...................................... 15


ADDING APP ADS AT ENTRY AND EXIT ....................................................................................... 15

USING 'APP AD' ADVANCED OPTIONS ............................................................ 17


PAUSE AND RESUMING ADS ................................................................................................. 17 IMPLEMENTING EVENT LISTENERS .......................................................................................... 17 UTILIZING DEVICE BACK BUTTON ........................................................................................... 19 ADDING A MARGIN FOR BANNER DOCKING ................................................................................ 20 PASSING SUB ID FROM APP ................................................................................................. 20

WORKING WITH APP RE-ENGAGEMENT .......................................................... 21


ADDING AN APP RE-ENGAGEMENT TO YOUR APP .......................................................................... 21 UPDATE YOUR MANIFEST ..................................................................................................... 21 ADD THE APP RE-ENGAGEMENT REGISTRATION CODE .................................................................... 21 HANDLE SYSTEM REBOOTS ................................................................................................... 22

WORKING WITH AUDIO ADS .......................................................................... 23


AUDIO AD CACHING ......................................................................................................... 24 AUDIO AD EVENT LISTENERS ............................................................................................... 25 AUDIO TRACKS ............................................................................................................... 25

APPFIREWORKS ANALYTICS .......................................................................... 27


REQUIRED PERMISSIONS ..................................................................................................... 27 ADDITIONAL PERMISSIONS (HIGHLY RECOMMENDED) ...................................................................... 27 APPFIREWORKS CODE ........................................................................................................ 28 APPFIREWORKS CUSTOM EVENTS ........................................................................................... 28

Copyright 2013. LeadBolt. All rights reserved

Page 3 of 29

What's New in v6.1


This version 6.1 release delivers a revolution for app developers, making it even easier to add our comprehensive monetization platform to your apps. This latest SDK comes with an awesome range of features, improvements, optimizations and includes powerful developer tools to ensure that your users are engaged and your app can be monetized to the highest level. Here are some of the highlights:

Display/Audio Ad Caching (new) Displaying in-app advertising seamlessly and without delaying user interaction is essential for high performing ad placements. This SDK includes support for pre-cached ad loading, allowing developers pre-load an ad, ready to be displayed instantly at a later time during app usage. LeadBolts pre-cached ads significantly reduce perceived ad loading time for users and provide a seamless app experience.

Auto-Scaling Banners (new) Supporting multiple resolution devices with banner ads is now easy using LeadBolts auto stretching banner ad type. Auto stretching banner ads automatically scale to match the users screen width, while maintaining the correct aspect ratio and adjusting the height accordingly, to ensure optimal ad display and a cohesive user experience on all devices and screen sizes.

Copyright 2013. LeadBolt. All rights reserved

Page 4 of 29

Performance & Ad Loading Speed Enhancements This SDK version includes some highly optimized enhancements delivering even better ad performance and dramatically increased ad loading speed. Overall, this SDK creates a better ad experience for users as well as providing performance enhancements for publishers. Other Changes: Due to requirements outlined in the Google Play developer policy (effective on the 23rd of September 2013 for existing apps), Notification Ads and App Icons are not supported by LeadBolt in this SDK.

Copyright 2013. LeadBolt. All rights reserved

Page 5 of 29

Adding LeadBolt Ads to your Android App


Starting as a LeadBolt App publisher
Step 1: Register for LeadBolt Publisher Portal access This is done by signing up for a publisher account at http://www.leadbolt.com. Once approved you can register your Apps and create ads. Setup your new App details on the Publisher portal. Once the App is added, you will be able to add an App Ad which can be a Banner Slot, Overlay, Rich Media, Interstitial, Floating Ad or an App Wall. Each App Ad has a unique section ID that you should have available for inclusion in the following code. Once this set ups are done, you are ready to start coding. Step 2: Get the Android SDK You will need to build your unified Android SDK in the LeadBolt Publisher Portal in the Download LeadBolt SDK section. Here you will have the option to customize the SDK to your needs. Please make a note of your package name given in the Publisher Portal. You will need to replace "com.<sdkpackagename>" in the sample codes in this document with your generated Package Name. Please note this document applies only to the unified SDK version 6.00 package or greater. Please note, the minimum Android OS Platform version required is 2.2 to use this SDK. Please compile with API Level 8 or greater.

Copyright 2013. LeadBolt. All rights reserved

Page 6 of 29

Setting up the Android Development Environment


Getting Started
It is recommended that you use the Eclipse IDE with the ADT Plugin to build your Android Apps: o Once a new project a created, make sure there a libs folder exists in your Project. o If not, simply right-click on the Project and click New -> Folder and enter libs as the Folder name

Linking in the Required Library


To link the LeadBolt SDK as a static library you will need to do the following: Step 1: Modifying Permissions The following permissions are required for the Ads to be served:

INTERNET ACCESS_NETWORK_STATE

Make sure that these are defined in your Project's AndroidManifest.xml file
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Optional permissions that may improve ad serving results through the location based targeting features or assist opt-out are:

READ_PHONE_STATE ACCESS_COARSE_LOCATION ACCESS_FINE_LOCATION ACCESS_ LOCATION_EXTRA_COMMANDS.

Where used, make sure that these are also defined in your Projects AndroidManifest.xml file
<uses-permission <uses-permission <uses-permission <uses-permission android:name="android.permission.READ_PHONE_STATE" /> android:name="android.permission.ACCESS_COARSE_LOCATION"/> android:name="android.permission.ACCESS_FINE_LOCATION"/> android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>

Copyright 2013. LeadBolt. All rights reserved

Page 7 of 29

Step 2: Add the LeadBolt static library To add the LeadBolt SDK static library, follow these steps: 1. Unzip the downloaded file and then in the Eclipse IDE, simply drag the generated jar file into your Projects libs folder. 2. When prompted Select how files should be imported into the project: and tick Copy Files option and click OK

3. Then, right-click on your Project and click Build Path -> Configure Build Path. 4. Under the window displayed, select Libraries tab. Click Add JARs, then select the jar file from the libs folder of your Project. 5. If you are planning to use ProGuard when exporting your app, you will need to add the following lines of code in your App's ProGuard config file typically located in the root directory on your App and is named proguard.cfg or proguard-project.txt. -keep class com.<sdkpackagename>.** { *; } -keepclassmembers class **.R$* { public static <fields>; } -keep class **.R$*

Copyright 2013. LeadBolt. All rights reserved

Page 8 of 29

Get Started with QuickStart Ads


Quick StartAds have been updated to support multiple screen resolutions automatically and to allow developers to get started even faster. The LeadBolt SDK now also comes bundled with AppFireworks in-app Analytics. This inclusion in your app will deliver deep insights into app usage, user behaviour, retention and user engagement. If you are adding LeadBolt to your App using our Quick StartAds is the recommended fastest and easiest way to get started. The simplest way to run LeadBolt ads are by integrating QuickStart Ads by adding these permissions in your App's AndroidManifest.xml and then adding the sample code your Apps main Activity class as seen by the example code following Add Required Permissions/Receivers/Services
<uses-permission <uses-permission <uses-permission <uses-permission <application android:name="android.permission.INTERNET" /> android:name="android.permission.ACCESS_NETWORK_STATE" /> android:name="android.permission.WAKE_LOCK" /> android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<service android:name="com.<sdkpackagename>.ReEngagementService"></service> <receiver android:name="com.<sdkpackagename>.ReEngagement" /> <service android:name="com.<sdkpackagename>.AdBootReceiverService"></service> <receiver android:name="< YOUR_APP_PACKAGE_NAME >.BootReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> </application>

Please note: Replace "<YOUR_APP_PACKAGE_NAME>" as noted above with your App's package name NOT the generated package name for this SDK.

Add the Additional AppFireworks Permissions (Highly Recommended)


<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <application <receiver android:name="com.appfireworks.android.track.AppTrackerReceiver" android:exported="true"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> </application>

Copyright 2013. LeadBolt. All rights reserved

Page 9 of 29

Add Required Code To run Quick StartAds in your App, simply need to add a few lines of code into your App. Main App Activity
/* Other imports here */ import com.<sdkpackagename>.AdController; import com.appfireworks.android.track.AppTracker; public class HelloWorld extends Activity { private AdController ad; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ad = new AdController(this, "MY_LB_SECTION_ID"); ad.loadStartAd("MY_LB_AUDIO_ID", "MY_LB_REENGAGEMENT_ID"); AppTracker.startSession(this, "APPFIREWORKS_API_KEY"); } @Override public void onPause() { super.onPause(); if(ad != null) { ad.destroyAd(); } if(!isFinishing()) { AppTracker.pause(getApplicationContext()); } } @Override public void onResume() { super.onResume(); AppTracker.resume(getApplicationContext()); } @Override public void onDestroy() { super.onDestroy(); if(ad != null) { ad.destroyAd(); } AppTracker.closeSession(getApplicationContext(),true); } }

Copyright 2013. LeadBolt. All rights reserved

Page 10 of 29

Handling System Reboots To handle device reboots and continue serving Ads, simply add a Boot Receiver file in your App
import android.content.Context; import android.content.Intent; import com.<sdkpackagename>.AdBootReceiver; public class BootReceiver extends AdBootReceiver { public void onReceive(Context ctx, Intent intent) { intent.putExtra("sectionid","YOUR_LB_REENGAGEMENT_ID"); super.onReceive(ctx, intent); // Other App specific code here } }

Copyright 2013. LeadBolt. All rights reserved

Page 11 of 29

Working with 'App Ad' templates


If you are an experienced developer and want to be in control, our unique ad serving portal lets you decide what ad types you want to run and where. You spent a lot of time making many decisions about how your app will look and function and you should be able to do the same with your advertising. Don't let the ad experience ruin your user's experience Our App Ad (SDK) ad type makes available a range of ad types within an App. Our powerful portal allows you to choose from a range of supported add types and customize them uniquely to your app Customizable Ad types available include Banners Interstitials Overlays App walls In-app alerts Rich Media Floating Ads NEW Auto-Scaling Banners

NEW

Be sure to add all these to your app. All these ad types are available when creating an App Ad by choosing the desired template and then implementing it using the standard App Ad loadAd() function. It is well proven that an ad experience that matches your app will lead to high user engagement. T

Copyright 2013. LeadBolt. All rights reserved

Page 12 of 29

Adding a LeadBolt 'App Ad' to your App code


Completing a simple integration
To add a LeadBolt "App Ad (SDK)" to your App is to add the code in your Apps Activity class as seen by the example code below:
/* Other imports here */ import com.<sdkpackagename>.AdController; public class HelloWorld extends Activity { private AdController ad; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ad = new AdController(this, "MY_LB_SECTION_ID"); ad.loadAd(); } public void onDestroy() { ad.destroyAd(); super.onDestroy(); } }

Once this code is included, access your publisher portal and add an App Ad (SDK) section and use the get code icon to retrieve the value for MY_LB_SECTION_ID. All Ad formats have Auto-Scaling option, which will scale the Ad to the appropriate size automatically on the Device. However, if your App requires, LeadBolt SDK does support fixed sized banners

Copyright 2013. LeadBolt. All rights reserved

Page 13 of 29

Advanced Integration with Caching


This SDK includes support for pre-cached ad loading, allowing you to pre-load an ad, ready to be displayed at a later time during app usage. This significantly reduces the ad loading time, as perceived by a user and is highly recommended for display ads triggered on exit (via back button). To add a caching "App Ad (SDK)" to your app, add the code in your Apps Activity class as seen by the example code below:
/* Other imports here */ import com.<sdkpackagename>.AdController; public class HelloWorld extends Activity { private AdController ad; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ad = new AdController(this, "MY_LB_SECTION_ID", new AdListener() { public void onAdLoaded() {} public void onAdClicked() {} public void onAdClosed() {} public void onAdCompleted() {} public void onAdFailed() {} public void onAdProgress() {} public void onAdAlreadyCompleted() {} public void onAdPaused() {} public void onAdResumed() {} public void onAdCached() { // Triggered when Ad is successfully cached // now simply call loadAd() to display Ad when cached ad.loadAd(); } }); ad.loadAdToCache(); } public void onDestroy() { ad.destroyAd(); super.onDestroy(); } }

Copyright 2013. LeadBolt. All rights reserved

Page 14 of 29

Making High Performance 'App Ad' templates


Adding App Ads at Entry and Exit
App Ads are exceptionally successful when run on App entry and App exit, where user engagement is often very high. Our display ad types (Interstitial, Overlay, Rich Media) are effective when placed at the app entry point and audio ads are recommended on exit, but display ads can also be used, if they can be placed before user exits (i.e. not when the home button is tapped) During app usage, we recommend that developers utilize a range of LeadBolts ad formats at different points of the app, depending on your app flow and structure. It is best to Cache the Ad when your App starts and then display the Ad instantly when the User is about to exit the App. Here is a code sample for using an App Ad on exit with Pre-Caching & complete with event listeners:

Copyright 2013. LeadBolt. All rights reserved

Page 15 of 29

private AdController ad; private Boolean adLoaded = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ad = new AdController(this, "YOUR_LB_SECTION_ID", new AdListener() { public void onAdLoaded() { loaded = true; } public void onAdClicked() {} public void onAdClosed() { finish(); } public void onAdCompleted() { finish(); } public void onAdFailed() { finish(); } public void onAdProgress() {} public void onAdAlreadyCompleted() { finish(); } public void onAdPaused() { finish(); } public void onAdResumed() {} public void onAdCached() {} }); ad.loadAdToCache(); // Other App Specific Code here } @Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { if (keyCode== KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if(!loaded && ad != null) { ad.loadAd(); return true; } } return super.onKeyDown(keyCode, event); }

Copyright 2013. LeadBolt. All rights reserved

Page 16 of 29

Using 'App Ad' Advanced options


We believe the effort you spend on you apps should be matched by the ad experience. Our powerful SDK has many advanced options available to the App developer enabling a range of sophisticated functions to get the best possible performance from ads in your apps. The following notes below will help you customize your in-app ad experience: Pause and Resuming Ads Pause and Resume Ad functionality is now available through the SDK as well. To pause the ad section simply call pauseAd() function on the AdController instance in your App. Pausing an Ad means no ad request will be sent to the Ad servers even though the loadAd() has been called. To resume the ad section call resumeAd() function on the AdController instance. Implementing Event Listeners For Ads, it is possible to listen for specific events with the Ad listener interface and write app specific code at these events. Event listeners exist for Ad loading, Ad clicks, Ad closures, Ad completions, Ad failures and Ad progress. Firstly your main activity class needs to implement the AdListener class, as shown in the example below:
public class MyClass extends Activity implements AdListener { .... }

Once your class implements AdListener, All 10 abstract methods will need to be implemented in your class, as shown below. To utilize these methods just add the app specific code you want to implement.

Copyright 2013. LeadBolt. All rights reserved

Page 17 of 29

public void onAdLoaded() { // add app specific code for this event here... // called when an ad is successfully displayed on device } public void onAdClicked() { // add app specific code for this event here... // called when an ad is clicked by user } public void onAdClosed() { // add app specific code for this event here... // called when the ad window is closed by user } public void onAdCompleted() { // add app specific code for this event here... // supported for Overlay template types. // called when ad window is closed with successful conversion } public void onAdFailed() { // add app specific code for this event here... // called when the ad request to the ad server has failed // e.g No Internet connection // if destroyAd needs to be called in this function please use // following code this.runOnUiThread(new Runnable() { public void run() { if(ad != null) { myController.destroyAd(); } } }); } public void onAdProgress() { // add app specific code for this event here... // call every x seconds while ad loading is in progress // x must be set by calling myController.setOnProgressInterval(x); // this function is off by default } public void onAdAlreadyCompleted() { // add app specific code for this event here... // triggered when loadAd() is called & current device has recorded // a successful conversion } public void onAdPaused() { // add app specific code for this event here... // triggered when loadAd() is called & pauseAd() has previously // been called by App Developer } public void onAdCached() { // add app specific code for this event here... // triggered once the Ad is successfully cached // when loadAdToCache is called } public void onAdResumed() { // add app specific code for this event here... // triggered when resumeAd() is called by App Developer }

Copyright 2013. LeadBolt. All rights reserved

Page 18 of 29

Now, finally when initializing the AdController class, you will need to pass the AdListener to it, as shown in the example below:
AdController ad = new AdController(this, "MY_LB_SECTION_ID", this); ad.loadAd();

In some cases it may be not suitable or appropriate to have your main activity class implement the AdListener interface. In those cases the following method is recommended.
AdController AdListener() public public public public public public public public public public }); ad.loadAd(); ad = { void void void void void void void void void void new AdController(this, "MY_LB_SECTION_ID", new onAdLoaded() {} onAdClicked() {} onAdClosed() {} onAdCompleted() {} onAdFailed() {} onAdProgress() {} onAdAlreadyCompleted() {} onAdPaused() { } onAdResumed() { } onAdCached() {}

Utilizing Device back button For App Ads, it is also possible for developers to programmatically link the device back button to the full screen ad window back button after an ad is clicked. A function onBackPressed() implements this functionality and also returns true when successfully initiated so that other app-specific code can be executed in this specific scenario. Sample code for linking the back buttons is shown below. It would typically be included in the main activity.

Copyright 2013. LeadBolt. All rights reserved

Page 19 of 29

@Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { if(ad.onBackPressed()) { // ie ad serving is in progress and back function // to previous ad window successful. // add additional app specific code here for this // scenario... } else { // any app specific code here for back button handling // outside the ad serving process } return true; // i.e tells activity action has been performed for the click } return super.onKeyDown(keyCode, event); }

Adding a Margin for Banner Docking The docking margin for SDK banner ads can be controlled within the app with an additional SDK function to handle device specific adjustments. This setAdditionalDockingMargin() function allows the dynamic adjustment of a banner ad placements vertical position by adding an additional docking margin setting (in pixels) in your publisher portal, for that specific section. This line has to be placed before standard loadAd() function is called. An example usage shown below:

AdController ad = new AdController(act, MY_LEADBOLT_SECTION_ID); // adjust the banner dynamically by 50 pixels from its designated // position ad.setAdditionalDockingMargin(50); ad.loadAd();

Passing Sub Id from App When passing a sub id, you must add the code 'ad.setSubId("YOUR_SUB_ID");' before you call loadAd();

Copyright 2013. LeadBolt. All rights reserved

Page 20 of 29

Working with App Re-Engagement


Adding an App Re-engagement to your App LeadBolts Google Play compliant, localized re-engagement notifications help ensure users are continuing to interact with your app. By targeting inactive users with re-engagement notifications, your inactive users are encouraged to return to your app and can do so with a single tap. To implement App Re-Engagement, the steps are as follows: Update your manifest To use App Re-engagement, the following additional lines must be added to the Manifest file.
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <application <receiver android:name="com.<sdkpackagename>.ReEngagement" /> <service android:name="com.<sdkpackagename>.ReEngagementService" /> <service android:name="com.<sdkpackagename>.AdBootReceiverService"></service> </application>

Add the App Re-engagement registration code This is achieved by adding the LeadBolt code inside your onCreate() function. Sample App code is given below showing simplest way to integrate LeadBolt App Re-engagement:
/* Other imports here */ import com.<sdkpackagename>.AdController; public class HelloWorld extends Activity { private AdController re; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); re = new AdController(getApplicationContext(), "MY_LB_REENGAGEMENT_ID"); re.loadReEngagement(); } }

Copyright 2013. LeadBolt. All rights reserved

Page 21 of 29

Handle system reboots In order to ensure App Re-engagement can continue to be received after system reboots the following additional code and configuration is required. You will need to add a Boot receiver to the android manifest. This means adding the following lines with the appropriate <YOUR_APP_PACKAGE_NAME> as noted below. Please Note: This will
be your App's package name NOT the generated package name from the Publisher Portal

<application <receiver android:name="<YOUR_APP_PACKAGE_NAME>.BootReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> </application>

Then you will need to create a new file for the boot receiver, name it BootReceiver.java which extends the AdBootReceiver class from the LeadBolt SDK and add the following code with your section id.:
import android.content.Context; import android.content.Intent; import com.<sdkpackagename>.AdBootReciver; public class BootReceiver extends AdBootReceiver { public void onReceive(Context ctx, Intent intent) { intent.putExtra("sectionid", "YOUR_REENGAGEMENT_ID"); super.onReceive(ctx, intent); } }

Copyright 2013. LeadBolt. All rights reserved

Page 22 of 29

Working with Audio Ads


Audio ads provide the next dimension in ad experience and app monetization for app developers and can work seamlessly alongside in app ads. Testing has shown that users respond with a higher level of engagement to audio ads with a corresponding greater degree of completion. Audio Ads are available to be run at any during your App's Lifecycle. Once the loadAudio function is called, the audio ad will be downloaded to the device. After the audio ad has finished playing, (usually about 15 seconds), the user will be prompted to shake the device to visit the landing page. Below is the sample code which shows how to run AudioAds at the start of your App.
/* Other imports here */ import com.<sdkpackagename>.AdController; public class HelloWorld extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); AdController audioad = new AdController(this, "MY_LB_SECTION_ID"); audioad.loadAudioAd(); } }

You can also run Audio Ads anywhere else in your Activity. You simply need to run the following lines in the appropriate function of your Activity class. Allow sufficient time for the audio ad to play before calling this function again.
AdController audioad = new AdController(this, "MY_LB_SECTION_ID"); audioad.loadAudioAd();

Copyright 2013. LeadBolt. All rights reserved

Page 23 of 29

Audio Ad Caching This SDK includes support for pre-cached ad loading, allowing you to pre-load an ad, ready to be displayed at a later time during app usage. This significantly reduces the ad loading time, as perceived by a user. To add a caching "Audio Ad (SDK)" to your app, use the code below:
/* Other imports here */ import com.<sdkpackagename>.AdController; public class HelloWorld extends Activity { Private AdController audio; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); audio = new AdController(this, "MY_LB_SECTION_ID", new AdAudioListener() { public void onAdProgress() {} public void onAdLoaded() {} public void onAdFinished() {} public void onAdFailed() {} public void onAdClosed() {} public void onAdClicked() {} public void onAdCached() { // called when Audio is successfully cached Audio.loadAd(); } }); audio.loadAudioAdToCache(); } }

Copyright 2013. LeadBolt. All rights reserved

Page 24 of 29

Audio Ad Event Listeners Audio Ads have their own set of Event Listeners which will assist App Developers listening to the ad progress throughout the lifecycle of the Audio Ad. Event listeners exist for Audio Ad loading, Audio Ad click (when a valid device shake is detected), closures, finishes, failures and Audio Ad progress. Below is some sample code that implements the Event Listeners so that these events can be handled during the lifecycle of the Audio Ad by the developer.
AdController audio = new AdController(this, "YOUR_LB_SECTION_ID", new AdAudioListener() { public void onAdProgress() { // called every x secs till audio ad is loaded or destroyed // audioAd.setOnProgressInterval(x); needs to be called // prior to calling loadAudioAd for the function to be triggered } public void onAdLoaded() { // called when audio ad is successfully loaded to be played } public void onAdFinished() { // called when audio ad finishes playing or a valid // user shake is detected } public void onAdFailed() { // called when audio ad fails to be loaded } public void onAdClosed() { // called when app developer calls audioAd.destroyAd() in the code } public void onAdClicked() { // called when a valid device shake is received // and user is taken to the ad offer. } public void onAdCached() { // called when Audio is successfully cached after // loadAudioAdToCache() is called } }); /* OPTIONAL SETTINGS: To trigger onAdProgress every 2 secs till the Audio is loaded, add the line below to your code. Change the integer value that is appropriate to your App. audio.setOnProgressInterval(2); */ audio.loadAudioAd();

Copyright 2013. LeadBolt. All rights reserved

Page 25 of 29

Audio Tracks LeadBolts Audio Tracks allow you to set auto play audio ads during app usage, on a set timeline of your choice. This is the ultimate set-andforget ad integration which allows you to continue monetizing active users, no matter how long they use your app for. Below is the sample code which shows how to run Audio Tracks throughout app usage:

/* Other imports here */ import com.<sdkpackagename>.AdController; public class HelloWorld extends Activity { private AdController audio; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); AdController audio = new AdController(this, "MY_LB_AUDIO_ID"); audio.loadAudioTrack(2); // value in mins // determines after how many mins to start the Audio Track. Change the value of 2 to suit your App. } @Override protected void onPause() { super.onPause(); if(audio != null) { audio.destroyAd(); } } @Override protected void onDestroy() { super.onDestroy(); if(audio != null) { audio.destroyAd(); } } @Override protected void onResume() { super.onResume(); if(audio == null) { audio = new AdController(this, "MY_LB_AUDIO_ID"); } audio.loadAudioTrack(1); // value in mins // Change the Interval to suit your App } }
Copyright 2013. LeadBolt. All rights reserved Page 26 of 29

AppFireworks Analytics
LeadBolt is bundling an awesome in-app analytics platform (AppFireworks) for free! Including AppFireworks analytics in your app will deliver deep insights into app usage, user behavior, retention and user engagement, as well as giving you access to a wide range of powerful developer tools including cross promotion, ad mediation, install tracking and much more! To integrate AppFireworks analytics into your app, you can follow the steps below, read our Quick Start Ad Guide or simply utilize the AppFireworks SDK documentation available from AppFireworks.

Required Permissions
The following permissions are required to integrate AppFireworks into your app. These permissions are also required by the LeadBolt SDK:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Additional Permissions (Highly Recommended)


The following permissions and receivers enable install tracking and ensure that analytics data is captured when users do not have an internet connection. Adding this is highly recommended:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <application <receiver android:name="com.appfireworks.android.track.AppTrackerReceiver" android:exported="true"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> </application>

Copyright 2013. LeadBolt. All rights reserved

Page 27 of 29

AppFireworks Code
Add the following code to your app, ensuring that the APPFIREWORKS_API_KEY is replaced with your unique AppFireworks key:
/* Other imports here */ import com.appfireworks.android.track.AppTracker; public class HelloWorld extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); AppTracker.startSession(this, "APPFIREWORKS_API_KEY"); } @Override public void onPause() { super.onPause(); if(!isFinishing()) { AppTracker.pause(getApplicationContext()); } } @Override public void onResume() { super.onResume(); AppTracker.resume(getApplicationContext()); } @Override public void onDestroy() { super.onDestroy(); AppTracker.closeSession(getApplicationContext(),true); }

AppFireworks Custom Events


To access in-depth, app specific data about your users and take advantage of the many powerful developer tools provided by AppFireworks, it is recommended that you log into your AppFireworks account and create custom events to track specific user actions in your app.

Copyright 2013. LeadBolt. All rights reserved

Page 28 of 29

Function Notes - SDK


Please note the following functions that are no longer present in v6.00 SDK. Some were previously noted as deprecated. AdController class loadNotification() no longer present in the SDK loadIcon() no longer present in the SDK loadOptin() no longer present in the SDK Previously removed/deprecated from AdController class hideAd() no longer present in the SDK showAd() no longer present in the SDK setAsynchTask(true) no longer present in the SDK. AdListener class onAdHidden no longer present in the SDK Following classes are no longer present in the LeadBolt Android SDK. Please remove any references to them in your JAVA Code or in the AndroidManifest.xml file. AdNotification, AdNotificationService, AdNotificationListener, AdIcon, AdIconService, AdIdReceiver, AdIdService, AdIdActivity, AdIdWatchdog, AdOptinListener

Copyright 2013. LeadBolt. All rights reserved

Page 29 of 29

Anda mungkin juga menyukai