Home

anand edited this page May 10, 2016 · 10 revisions
Clone this wiki locally

Overview

The CrossChannel Android SDK enables high volume Android publishers to earn high CPMs via highly engaging display interstitials, video Ads and rewarded video Ads. Banner formats have been deprecated as of version 3.5 along with framed and styled ads.

  • Current CrossChannel SDK Version: 3.6.2 (November 19, 2015 Release)
  • Android Version Support: 2.2+
  • Supported formats: Display Interstitials, Video Ads, Rewarded Video Ads
  • Supported Setups: Standalone SDK, Google AdMob, Twitter MoPub, Yahoo Flurry, Unity, PhoneGap, ANE

How to add the CrossChannel Android SDK to your Android application

Mentioned below are the steps to follow for adding CrossChannel Android SDK to your Android application and to initialize the SDK

Step 1: Getting started with CrossChannel

Step 2: Add CrossChannel Android SDK to your project

  • Copy the downloaded MdotM-Android-SDK-3.6.2.jar SDK file into your Eclipse libs folder. Once added, add this file to the build path.

Adding Android SDK

Step 3: Modify your Android Manifest

  • Define the following activities in the AndroidManifest.xml file

You may choose to add other themes like Fullscreen - without status bar as mentioned below:

 android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
  • Add the following '''mandatory''' permissions to your manifest file.

Optionally, add the following permissions to get the cache Ads and to identify the network bandwidth for serving Ads accordingly:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  • Download Google Play Services and use as Library. Your application tag should contain following line

  • If you compile with API level 18 or above enabling proguard, then add the following line in your proguard file:

    -dontwarn android.webkit.**

Step 4: Initialize the SDK

Create an instance of MdotMAdRequest and put in your appkey that you set up on the CrossChannel website:

MdotMAdRequest request = new MdotMAdRequest();
request.setAppKey("[INSERT_APP_KEY]");
request.setTestMode("0");

Displaying Ads

Use the code below to display your preferred ad format:

Interstitials and Video Ads

Create an instance of MdotMInterstitial class:

 MdotMInterstitial interstitial = new MdotMInterstitial(activitycontext);

Implement MdotMAdEventListener listeners:

public void onReceiveInterstitialAd();
public void onFailedToReceiveInterstitialAd();
public void onInterstitialAdClick();
public void onDismissScreen();
public void onInterstitialDismiss();
public void onLeaveApplicationFromInterstitial();
public void willShowInterstitial();
public void didShowInterstitial();

Set Test Mode

If video ads are required then set test as "video" otherwise interstitial ads will be received

request.setTestMode("video"); // To get video ads

Call loadInterstitial

Be sure to pass your MdotMAdEventListeners and request object:

interstitial.loadInterstitial(this, request);

Implement your showInterstitial handling

Once onReceiveInterstitialAd is called, you must call showInterstitial(<activitycontext>):

interstitial.showInterstitial(this);

Rewarded Video Ads

The implementation of Rewarded Video is the same as the above, except that instead of calling loadInterstitial, you call the following:

interstitial.loadRewardedVideo(this, request, reward);

and implement the following listener:

public void onRewardedVideoComplete(boolean skipped, String reward);

If the user completes the video, skipped is false and the user should be rewarded.

If the user skips the video, skipped is true and the user should not be rewarded.

The additional reward parameter should be used in applications where multiple kinds of rewards can be offered to the user. If there is no ambiguity in reward, an empty string can be provided.

Native Ads

CrossChannel's Native Ad SDK enables high volume publishers to maximize user experience and monetization performance.

Set up the parameter values for MdotMAdRequest

Set up MdotMAdRequest and put in your appkey that you set up on the CrossChannel web site

MdotMAdRequest request = new MdotMAdRequest();
request.setAppKey("[INSERT_APP_KEY]");
request.setTestMode("native");

Create an instance of the MdotMNativeView class

MdotMNativeView nativeView = new MdotMNativeView(activitycontext);                                                                  

and set up the following MdotMAdEventListeners for when a native ad is received

public void onReceiveNativeAd(ArrayList<MdotMNativeAd> nativeAd);                                                                        

and when an ad fails to load:

public void onFailedToReceiveNativeAd();                                                                        

Call loadNativeAd

Pass your MdotMAdEventListeners and request object:

nativeView.loadNativeAd(this, request);

Implement Key Listeners

Implement the key listener functions that are invoked when an ad has loaded. When a native ad loads, it is ready to be shown in your app. This can be done in the first listener as follows:

public void onReceiveNativeAd(ArrayList<MdotMNativeAd> nativeAd)
{
   String title = nativeAd.get(0).getTitle();
   String body = nativeAd.get(0).getBody();

   // Add code here to create a custom view that uses the ad properties
   LinearLayout nativeAdContainer = new LinearLayout(this);
   TextView titleLabel = new TextView(this);
   ImageView profileIconImageView=new ImageView(this);
   titleLabel.setText(titleForAd);
   nativeAdContainer.addView(titleLabel);

   // Load the cover image and icon into an ImageView using an helper function
   nativeAd.get(0).displayImage(nativeAd.get(0).getIcon(),profileIconImageView, mContext);
   ...

   // Add the ad to your layout
   LinearLayout mainContainer = (LinearLayout)findViewById(R.id.MainContainer);
   mainContainer.addView(nativeAdContainer);

   // Register the native ad view with the native ad instance
   nativeAd.get(0).registerView(nativeAdContainer,nativeAd.get(randomnativead),activity);


 }

The following MdotMNativeAd properties will always have values:

  • title - 25 chars
  • body - 100 chars
  • icon - 80x80 image
  • coverImage - 1200x627 image
  • callToAction - 8 chars and should be used to display the native ad. Ad metadata that you receive can be cached and re-used for up to 24 hours.

The SDK will log the impression and handle the click automatically via the registerView call, which makes the whole view clickable.

  • To re-use the view to show different ads over time, call unregisterView before registering the same view with a different instance of MdotMNativeAd.

    nativeAd.get(0).unregisterView(nativeAdContainer);

Email sdksupport@CrossChannel.com for a Sample Application for Native Ads.

Testing and Troubleshooting

The following are the test modes to set to test your SDK implementation.

Set your test mode to "1" to get test Ads

request.setTestMode("1");

or to get video test Ads

request.setTestMode("video");

or to get native test ads

request.setTestMode("native");

This will ensure 100% fill rate.

To test your application for lack of fill, set your test mode to nofill

request.setTestMode("nofill");

This will ensure 0% fill rate.

When you are done testing, revert back to:

request.setTestMode("0");

Sample Application

Our sample application provide fully working examples of the CrossChannel Android SDK for displaying Interstitials, Videos and Rewarded Video Ads.

Mentioned below are the steps to access and setup the sample application:

  • Download the SDK from GitHub and import into your workspace.
  • Set google-play-service.lib as a library project as shown in the screenshot below

Sampleapp Eclipse Screenshot

Support

Email sdksupport@CrossChannel.com for assistance - we are happy to help!