Skip to main content

Splash

1、Load an ad

  • Developers can preload ads before displaying them.
  • Create an advertisement object TPSplash, some advertisement platforms require acitivity to be passed in, otherwise the advertisement cannot be successfully loaded
  • You don't need to pass in the container when loadingAd, you can pass in the container when displaying the ad
// Pangle,Yandex and Google Admob advertising platforms require incoming activity
TPSplash tpSplash = new TPSplash(activity,"AdUnitID");
tpSplash.setAdListener(new SplashAdListener());
tpSplash.loadAd(null);

2、Show splash ad

  • During cold start, call loadAd as soon as possible, and display the ad immediately after listening to the onAdLoaded callback
  • During hot start, the advertisement can be loaded in advance. When the event of switching the foreground of the device is detected, the isReady() method is called to check whether there is an available advertisement. When there is an available advertisement, the show method is called to display the advertisement.
  • The developer needs to provide an ad container, and some of the three parties return it as a view; after listening to the onAdClosed callback, remove the container
if(tpSplash.isReady()) {
tpSplash.showAd(adContainer);
}

3、Register Ad Event Callback

  • Note: Don't perform the retry loading method ad in onAdFailed callback – it'll cause a lot of useless requests and could make your app run slowly.
  • After listening to the onAdClosed callback, remove the container adContainer
tpSplash.setAdListener(new SplashAdListener() {

@Override // Callback when the first ad source is loaded successfully;A load will only be called back once
public void onAdLoaded(TPAdInfo tpAdInfo, TPBaseAd tpBaseAd) {}

@Override // Splash ad clicked
public void onAdClicked(TPAdInfo tpAdInfo) {}

@Override // Splash ad appears on the screen
public void onAdImpression(TPAdInfo tpAdInfo) {}

@Override // Splash ad failed to load
public void onAdLoadFailed(TPAdError error) {}

@Override // Splash ad closed
public void onAdClosed(TPAdInfo tpAdInfo) {
adContainer.removeAllViews();
}
});

4、Code

  • We recommend that you use the SplashActivity to understand the use of the SDK.