interstitial ads는 앱의 인터페이스를 일시적으로 덮는 전체 화면 또는 전체 페이지 광고입니다. 이 광고는 일반적으로 게임에서 레벨을 완료한 후나 주요 뷰 사이를 탐색할 때와 같이 자연스러운 일시 중지 또는 전환 시점에 표시됩니다.
다음 섹션에서는 interstitial ad를 로드하고 표시하는 방법을 보여줍니다.
interstitial ad를 로드하려면 먼저 ad unit에 해당하는 MaxInterstitialAd 객체를 인스턴스화합니다.
그런 다음 해당 객체의 loadAd() 메서드를 호출합니다.
광고가 준비되었을 때 알림을 받을 수 있도록 MaxAdListener를 구현합니다 (다른 광고 관련 이벤트에 대해서도 알림을 받게 됩니다).
public class ExampleActivity extends Activity
implements MaxAdListener
{
private MaxInterstitialAd interstitialAd;
private int retryAttempt;
void createInterstitialAd()
{
interstitialAd = new MaxInterstitialAd( "«ad-unit-ID»", this );
interstitialAd.setListener( this );
// Load the first ad
interstitialAd.loadAd();
}
// MAX Ad Listener
@Override
public void onAdLoaded(final MaxAd maxAd)
{
// Interstitial ad is ready to be shown. interstitialAd.isReady() will now return 'true'
// Reset retry attempt
retryAttempt = 0;
}
@Override
public void onAdLoadFailed(final String adUnitId, final MaxError error)
{
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
retryAttempt++;
long delayMillis = TimeUnit.SECONDS.toMillis( (long) Math.pow( 2, Math.min( 6, retryAttempt ) ) );
new Handler().postDelayed( new Runnable()
{
@Override
public void run()
{
interstitialAd.loadAd();
}
}, delayMillis );
}
@Override
public void onAdDisplayFailed(final MaxAd maxAd, final MaxError error)
{
// Interstitial ad failed to display. AppLovin recommends that you load the next ad.
interstitialAd.loadAd();
}
@Override
public void onAdDisplayed(final MaxAd maxAd) {}
@Override
public void onAdClicked(final MaxAd maxAd) {}
@Override
public void onAdHidden(final MaxAd maxAd)
{
// Interstitial ad is hidden. Pre-load the next ad
interstitialAd.loadAd();
}
}
class ExampleActivity : Activity(), MaxAdListener
{
private lateinit var interstitialAd: MaxInterstitialAd
private var retryAttempt = 0.0
fun createInterstitialAd()
{
interstitialAd = MaxInterstitialAd( "«ad-unit-ID»", applicationContext )
interstitialAd.setListener( this )
// Load the first ad
interstitialAd.loadAd()
}
// MAX Ad Listener
override fun onAdLoaded(maxAd: MaxAd)
{
// Interstitial ad is ready to be shown. interstitialAd.isReady() will now return 'true'
// Reset retry attempt
retryAttempt = 0.0
}
override fun onAdLoadFailed(adUnitId: String?, error: MaxError?)
{
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
retryAttempt++
val delayMillis = TimeUnit.SECONDS.toMillis( Math.pow( 2.0, Math.min( 6.0, retryAttempt ) ).toLong() )
Handler().postDelayed( { interstitialAd.loadAd() }, delayMillis )
}
override fun onAdDisplayFailed(ad: MaxAd?, error: MaxError?)
{
// Interstitial ad failed to display. AppLovin recommends that you load the next ad.
interstitialAd.loadAd()
}
override fun onAdDisplayed(maxAd: MaxAd) {}
override fun onAdClicked(maxAd: MaxAd) {}
override fun onAdHidden(maxAd: MaxAd)
{
// Interstitial ad is hidden. Pre-load the next ad
interstitialAd.loadAd()
}
}
권장 사항: interstitial ads 표시하기
interstitial ad를 표시하려면 생성한 MaxInterstitialAd 객체에서 showAd( this )를 호출합니다.
if ( interstitialAd.isReady() )
{
// `this` is the activity that will be used to show the ad
interstitialAd.showAd( this );
}
if ( interstitialAd.isReady )
{
// `this` is the activity that will be used to show the ad
interstitialAd.showAd(this)
}
AppLovin MAX SDK는 잠금 화면에 interstitial ads를 표시할 수 있는 API를 제공합니다. 이 연동의 사용 사례로는 일반적으로 잠금 화면에 표시되는 오디오 앱 등이 있습니다.
잠금 화면에 표시할 interstitial ad를 로드할 때는 MaxInterstitialAd에 추가 파라미터를 설정해야 하며, 전달하는 Activity는 LifecycleOwner 인터페이스를 구현해야 합니다.
⋮
⋮
public class ExampleActivity extends Activity
implements MaxAdListener, LifecycleOwner
{
private FrameLayout adContainerView;
private MaxInterstitialAd interstitialAd;
private int retryAttempt;
void createInterstitialAd()
{
interstitialAd = new MaxInterstitialAd( "«ad-unit-ID»", this );
interstitialAd.setExtraParameter( "container_view_ads", "true" );
interstitialAd.setListener( this );
// Load the first ad
interstitialAd.loadAd();
}
// MAX Ad Listener
⋮
}
⋮
⋮
class ExampleActivity : Activity(), MaxAdListener, LifecycleOwner
{
private lateinit var adContainerView: FrameLayout
private lateinit var interstitialAd: MaxInterstitialAd
private var retryAttempt = 0.0
fun createInterstitialAd()
{
interstitialAd = MaxInterstitialAd( "«ad-unit-ID»", applicationContext )
interstitialAd.setExtraParameter( "container_view_ads", "true" )
interstitialAd.setListener( this )
// Load the first ad
interstitialAd.loadAd()
}
// MAX Ad Listener
⋮
}
잠금 화면 interstitial ad를 표시하려면 광고의 ViewGroup과 함께 showAd(…)를 호출합니다.
if ( interstitialAd.isReady() )
{
// `this` is the activity that will be used to show the ad
interstitialAd.showAd( adContainerView, getLifecycle(), this );
}
if ( interstitialAd.isReady )
{
// `this` is the activity that will be used to show the ad
interstitialAd.showAd( adContainerView, getLifecycle(), this )
}
이 기능을 지원하는 네트워크는 AppLovin의 Ads Manager 및 AppLovin Exchange입니다.
커스텀 어댑터 또는 AppLovin의 오픈 소스 어댑터 중 하나에 지원을 추가하려면 다음 showInterstitialAd(…) 메서드를 오버라이드합니다.
@Override
public void showInterstitialAd(final MaxAdapterResponseParameters parameters,
final ViewGroup containerView,
final Lifecycle lifecycle,
final Activity activity,
final MaxInterstitialAdapterListener listener)
{
⋮
}