InterstitialAd

abstract class InterstitialAd

알려진 직접 서브클래스
AdManagerInterstitialAd

Google Ad Manager 게시자의 경우 페이지 변경, 앱 실행 또는 게임 레벨 로드와 같은 자연스러운 전환 시점에 전체 페이지로 게재되는 광고입니다.


페이지 변경, 앱 실행 또는 게임 레벨 로드와 같은 자연스러운 전환 시점에 전체 페이지 광고 경험을 제공합니다. 전면 광고는 사용자 환경에서 광고를 삭제하는 닫기 버튼을 사용합니다.

샘플 코드

public class MyActivity extends Activity {
    private InterstitialAd interstitialAd;
    private Button nextLevelButton;
    private TextView textView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Create a full screen content callback.
        FullScreenContentCallback fullScreenContentCallback = new FullScreenContentCallback() {
            @Override
            public void onAdDismissedFullScreenContent() {
               interstitialAd = null;
               // Proceed to the next level.
               goToNextLevel();
            }
        };

        // Load an interstitial ad. When a natural transition in the app occurs (such as a level
        // ending in a game), show the interstitial. In this simple example, the press of a
        // button is used instead.
        //
        // If the button is clicked before the interstitial is loaded, the user should proceed to
        // the next part of the app (in this case, the next level).
        //
        // If the interstitial is finished loading, the user will view the interstitial before
        // proceeding.
        InterstitialAd.load(
            this,
            "myAdUnitId",
            new AdRequest.Builder().build(),
            new InterstitialAdLoadCallback() {
                @Override
                public void onAdLoaded(@NonNull InterstitialAd ad) {
                    interstitialAd = ad;
                    interstitialAd.setFullScreenContentCallback(fullScreenContentCallback);
                }

                @Override
                public void onAdFailedToLoad(@NonNull LoadAdError adError) {
                    // Code to be executed when an ad request fails.
                }
            });

        // Create the button to go to the next level.
        nextLevelButton = new Button(this);
        nextLevelButton.setText("Next Level");
        nextLevelButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // Show the interstitial if it is ready. Otherwise, proceed to the next level
                // without ever showing it.
                if (interstitialAd != null) {
                    interstitialAd.show(MyActivity.this);
                } else {
                    // Proceed to the next level.
                    goToNextLevel();
                }
            }
        });

        // Add the next level button to the layout.
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        layout.addView(nextLevelButton);

        // Create a TextView to display the current level.
        textView = new TextView(this);
        textView.setText("Level 1");
        layout.addView(textView);

        setContentView(layout);
    }

    public void goToNextLevel() {
        // Show the next level, and disable the next level button since there are no more levels.
        nextLevelButton.setEnabled(false);
        textView.setText("Level 2");
    }
}

요약

공개 생성자

공개 함수

abstract String

광고 단위 ID를 반환합니다.

abstract FullScreenContentCallback?

InterstitialAdFullScreenContentCallback를 가져옵니다.

abstract OnPaidEventListener?

InterstitialAdOnPaidEventListener를 가져옵니다.

abstract Long

InterstitialAd의 게재위치 ID를 반환합니다.

abstract ResponseInfo

로드된 광고의 ResponseInfo 객체를 반환합니다.

java-static Boolean
isAdAvailable(context: Context, adUnitId: String)

이 함수는 지원 중단되었습니다.

대신 isAdAvailable을 사용하세요.

java-static Unit
load(
    context: Context,
    adUnitId: String,
    adRequest: AdRequest,
    loadCallback: InterstitialAdLoadCallback
)

InterstitialAd를 로드합니다.

java-static InterstitialAd?
pollAd(context: Context, adUnitId: String)

이 함수는 지원 중단되었습니다.

대신 pollAd를 사용하세요.

abstract Unit
setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
)

광고가 표시되고 전체 화면 콘텐츠가 닫힐 때 호출될 콜백을 등록합니다.

abstract Unit
setImmersiveMode(immersiveModeEnabled: Boolean)

이 전면 광고 객체가 몰입형 모드로 표시되는지 여부를 제어하는 플래그를 설정합니다.

abstract Unit

이 광고로 수익이 발생한 것으로 추정될 때 호출될 콜백을 등록합니다.

abstract Unit
setPlacementId(placementId: Long)

전면 광고의 게재위치 ID를 설정합니다.

abstract Unit
show(activity: Activity)

전면 광고를 표시합니다.

공개 생성자

InterstitialAd

InterstitialAd()

공개 함수

getAdUnitId

abstract fun getAdUnitId(): String

광고 단위 ID를 반환합니다.

getFullScreenContentCallback

abstract fun getFullScreenContentCallback(): FullScreenContentCallback?

InterstitialAdFullScreenContentCallback를 가져옵니다.

getOnPaidEventListener

abstract fun getOnPaidEventListener(): OnPaidEventListener?

InterstitialAdOnPaidEventListener를 가져옵니다.

getPlacementId

abstract fun getPlacementId(): Long

InterstitialAd의 게재위치 ID를 반환합니다.

getResponseInfo

abstract fun getResponseInfo(): ResponseInfo

로드된 광고의 ResponseInfo 객체를 반환합니다. 광고가 로드될 때까지 null을 반환합니다.

isAdAvailable

java-static fun isAdAvailable(context: Context, adUnitId: String): Boolean

startPreload에서 로드된 사용 가능한 전면 광고가 있는 경우 true을 반환합니다.

load

java-static fun load(
    context: Context,
    adUnitId: String,
    adRequest: AdRequest,
    loadCallback: InterstitialAdLoadCallback
): Unit

InterstitialAd를 로드합니다.

매개변수
context: Context

활동 또는 애플리케이션 컨텍스트입니다.

adUnitId: String

광고 단위 ID입니다.

adRequest: AdRequest

타겟팅 정보가 포함된 광고 요청입니다.

loadCallback: InterstitialAdLoadCallback

전면 광고 로드가 완료될 때 호출되는 콜백입니다.

pollAd

java-static fun pollAd(context: Context, adUnitId: String): InterstitialAd?

startPreload에서 로드된 다음 전면 광고를 가져옵니다. 광고를 사용할 수 없는 경우 null에서 가져옵니다.

setFullScreenContentCallback

abstract fun setFullScreenContentCallback(
    fullScreenContentCallback: FullScreenContentCallback?
): Unit

광고가 표시되고 전체 화면 콘텐츠가 닫힐 때 호출될 콜백을 등록합니다.

setImmersiveMode

abstract fun setImmersiveMode(immersiveModeEnabled: Boolean): Unit

이 전면 광고 객체가 몰입형 모드로 표시되는지 여부를 제어하는 플래그를 설정합니다. show 전에 이 메서드를 호출합니다. show 중에 이 플래그가 설정되어 있고 몰입형 모드가 지원되면 SYSTEM_UI_FLAG_IMMERSIVE_STICKY 및 SYSTEM_UI_FLAG_HIDE_NAVIGATION이 전면 광고에 설정됩니다.

setOnPaidEventListener

abstract fun setOnPaidEventListener(listener: OnPaidEventListener?): Unit

이 광고로 수익이 발생한 것으로 추정될 때 호출될 콜백을 등록합니다.

setPlacementId

abstract fun setPlacementId(placementId: Long): Unit

전면 광고의 게재위치 ID를 설정합니다.

이 게재위치 ID가 보고에 포함되도록 하려면 광고를 표시하기 전에 이 메서드를 호출하세요.

매개변수
placementId: Long

구성된 게재위치에 대해 AdMob UI에서 제공하는 긴 정수입니다.

표시

abstract fun show(activity: Activity): Unit

전면 광고를 표시합니다.

매개변수
activity: Activity

광고를 표시할 Activity 컨텍스트입니다.