-
Notifications
You must be signed in to change notification settings - Fork 4
Interstitial Integration
Interstitial ads provide full-screen experiences, commonly incorporating rich media to offer a higher level of interactivity compared to banner ads. Interstitials are typically shown during natural transitions in your app, e.g. after completing a game level, or while waiting for a new view to load. You can use the InterstitialAdManager object and its associated listeners to fetch and display interstitial ads in your app.
Before integrating banner ads in your app, you’ll need to go through the steps in our Getting Started Guide to integrate the SDK into your project. #Sample code And obtain Interstitial Ads Steps
obtain sample code:
For a complete example, check out the pegasi-sample.
obtain Interstitial Ads Steps:
1.Create InterstitialAdManager and set posid
2.Set callback interface which is InterstitialAdCallBack
3.Load interstitial Ad
4.Display interstitial Ad
#Load interstitial ads in your app ###Check your AndroidManifest.xml file Be sure you have the following permissions:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />**Note:**The INTERNET permission is required which is used to access the internet to get ad. The ACCESS_NETWORK_STATE or ACCESS_WIFI_STATE permission are optional which used for checking whether there is avaible Internet connection(suggest configure them).
if you integrated PEGASI SDK Ext Version , Please declare the following activities:
<!--for Mopub -->
<activity android:name="com.mopub.mobileads.MoPubActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.common.MoPubBrowser"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"/>
<!--for Mopub-->Add this tag to your to use Google Play Services:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />Important Note: If compiling against API Level below 13, exclude screenSize from the manifest entries.
###1.Create InterstitialAdManager and set posid ###2.Set callback interface which is InterstitialAdCallBack
if(interstitialAdManager == null) {
//step1 : create interstitialAdManager
//The first parameter:Context
//The second parameter: ADUnitId
interstitialAdManager = new InterstitialAdManager(this, ADUnitId);
}
//step2 : set callBack listener if you need .
interstitialAdManager
.setInterstitialCallBack(new InterstitialAdCallBack() {
@Override
public void onAdLoadFailed(int errorCode) {
}
@Override
public void onAdLoaded() {
isAdReady = true;
}
@Override
public void onAdClicked() {
//ad clicked
}
@Override
public void onAdDisplayed() {
//ad display
}
@Override
public void onAdDismissed() {
//click close button that ad destory
}
});
isAdReady = false;
###3.Load interstitial Ad
//step3 : start load interstitialAd by InterstitialAdManager#loadAd()
interstitialAdManager.loadAd();###4.Display interstitial Ad
//step4 : if load interstitialAd success ,
//you can show Ad by InterstitialAdManager#showAd()
if(interstitialAdManager != null && isAdReady) {
interstitialAdManager.showAd();
}See InterstitalAdSampleActivity.java from the pegasi-sample for a full example.