Splash
The ad style appears at the natural endpoints and transition segments. The supported ad size is 9:20. The effect is shown in the figure:
Introduction
Ad styles that appear at natural endpoints and transition sections support ad sizes of 9:16, 1:2, and 2:3. The effect is as shown below:
9:20 |
---|
![]() |
Reminder: Splash screen supports two forms of displaying ads: View and Activity. Please choose to access as needed; the following configurations will be differentiated according to View and Activity.
Build Components
View: Please add TSplashView in xml.
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.cloud.hisavana.sdk.api.adx.TSplashView
android:id="@id/splash_ad"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="0dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
Activity: No need to build xml file.
Load Ads
Strongly Recommended: Avoid special reasons that cause the app to get stuck on the opening screen; please add a timeout mechanism on the app opening screen. For example, if the opening screen ad fails to display successfully within about 3 seconds, please jump to the page by yourself.
View:Please set the corresponding parameters and listening callbacks.
// Bind views in xml layout
TSplashView tSplashView = findViewById(R.id.splash_ad);
// Set the ad slot ID, where "splash_id" is the splash ad slot ID
tSplashView.setPlacementId("splash_id");
// Set up ad listeners
tSplashView.setListener(new TAdListener());
// Listen for skip actions
tSplashView.setSkipListener(new TAdOnSkipListener());
// Load ads
tSplashView.loadAd();
// Example: 'Timeout Mechanism'
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
// Execute jump logic
}
}, 3000);
// splash screen skip action listener
private class TAdOnSkipListener implements OnSkipListener {
@Override
public void onClick() {
Log.i(TAG, "skip button click");
}
@Override
public void onTimeEnd() {
Log.i(TAG, "time end");
}
}
// Ad listener, listens for callbacks of ad request timeout, loading completion (filling), display, click, exception, and close actions
private static class TAdListener extends AdListener {
// Abnormal callback (applicable ad slots: all ad slots)
@Override
public void onError(TaErrorCode adError) {
Log.d(TAG,"Ad failed callback");
}
// Loading completion callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onAdLoaded() {
Log.d(TAG,"Ad loaded callback");
}
// Click callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onAdClicked() {
Log.d(TAG,"Ad click callback");
}
// Display callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onAdShow() {
Log.d(TAG,"Ad show callback");
}
// Request timeout callback (applicable ad slots: all ad slots)
@Override
public void onTimeOut() {
Log.d(TAG,"Ad request timeout callback");
}
// Close callback (applicable ad slots: Splash, Interstitial, Reward)
@Override
public void onAdClosed() {
Log.d(TAG,"Ad close callback");
}
}
If you want to add a sublayout, such as displaying the logo and name at the bottom, etc.
/**
* Optional
* Allow the application to pass in the logo and name by adding a sublayout
* The sdk internally loads a sublayout to render the bottom media logo information. The bottom area is 14% of the height of the mobile phone screen.
*/
View logoLayout = LayoutInflater.from(this).inflate(R.layout.splash_logo_layout, null, false);
tSplashAd.setLogoLayout(logoLayout);
Activity: Please set the corresponding parameters and listening callbacks.
// Initialize the open-screen advertising object, where "splash_id" is the open-screen advertising slot ID
TSplash tSplash = new TSplash(context, "splash_id");
// Set up ad listeners
tSplash.setListener(new TAdListener());
// Listen for skip actions
tSplash.setSkipListener(new TAdOnSkipListener());
// Load ads
tSplash.loadAd();
// Example: 'Timeout Mechanism'
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
// Execute jump logic
}
}, 3000);
// splash screen skip action listener
private class TAdOnSkipListener implements OnSkipListener {
@Override
public void onClick() {
Log.i(TAG, "skip button click");
}
@Override
public void onTimeEnd() {
Log.i(TAG, "time end");
}
}
// Ad listener, listens for callbacks of ad request timeout, loading completion (filling), display, click, exception, and close actions
private static class TAdListener extends AdListener {
// Abnormal callback (applicable ad slots: all ad slots)
@Override
public void onError(TaErrorCode adError) {
Log.d(TAG,"Ad failed callback");
}
// Loading completion callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onAdLoaded() {
Log.d(TAG,"Ad loaded callback");
}
// Click callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onAdClicked() {
Log.d(TAG,"Ad click callback");
}
// Display callback (applicable ad slots: Splash, Interstitial, Banner, Reward)
@Override
public void onAdShow() {
Log.d(TAG,"Ad show callback");
}
// Request timeout callback (applicable ad slots: all ad slots)
@Override
public void onTimeOut() {
Log.d(TAG,"Ad request timeout callback");
}
// Close callback (applicable ad slots: Splash, Interstitial, Reward)
@Override
public void onAdClosed() {
Log.d(TAG,"Ad close callback");
}
}
If you want to add a sublayout, such as displaying the logo and name at the bottom, etc.
/**
* Optional
* Allow the application to pass in the logo and name by adding a sublayout
* The sdk internally loads a sublayout to render the bottom media logo information. The bottom area is 14% of the height of the mobile phone screen.
*/
View logoLayout = LayoutInflater.from(this).inflate(R.layout.splash_logo_layout, null, false);
tSplashAd.setLogoLayout(logoLayout);
Important Reminder
Scenario: After clicking on the open-screen advertisement to open it, the method for handling the need to jump to the homepage when returning to the main process is as follows:
- Record the click status of the global variable "isClicked = true" in the ad listener "onAdClicked()",
- In the "onResume()" method of the life cycle, do the logic processing of jumping to the main page and removing the open view.
View: Implemented as follows.
// Ad listener "onAdClicked()"
@Override
public void onAdClicked() {
super.onAdClicked();
isClicked = true;
Log.d(TAG,"SplashAdActivity --> onAdClicked --> Clicked on the ad");
}
// Life cycle "onResume()"
@Override
protected void onResume() {
super.onResume();
if (isClicked){
// TODO Jump to home page
...
// Remove splash screen view
if (splashView!= null && tSplashView.getParent() != null){
((ViewGroup) tSplashView.getParent()).removeView(splashView);
}
}
}
Activity:No action required.
Display Ads
View: Please display the opening screen advertisement.
if (tSplashView != null) {
tSplashView.show();
}
Activity:Please display the opening screen advertisement.
if (tSplash != null) {
tSplash.show();
}
Destroy Ads
Please recycle ads in time, otherwise the App will cause memory leaks.
View: Please destroy the ad view.
@Override
protected void onDestroy() {
super.onDestroy();
if (tSplashView != null) {
tSplashView.destroy();
tSplashView = null;
}
}
Activity:Please destroy the ad object.
@Override
protected void onDestroy() {
super.onDestroy();
if (tSplash != null) {
tSplash.destroy();
tSplash = null;
}
}
Other APIs
View:The details are as follows.
API call | Introduce |
---|---|
tSplashView.isAdValid() | Whether the current ad is within the validity period |
tSplashView.isReady() | Whether the current ad is loaded successfully and within the delivery period, if it is displayed, otherwise it is not displayed. |
tSplashView.isOfflineAd() | Is the current ad offline |
tSplashView.getFillAdType() | Whether the current filled advertisement is offline or online advertising; 1: offline advertisement, 0: online advertisement, -1: no filling |
Activity:The details are as follows.
API call | Introduce |
---|---|
tSplash.isAdValid() | Whether the current ad is within the validity period |
tSplash.isReady() | Whether the current ad is loaded successfully and within the delivery period, if it is displayed, otherwise it is not displayed. |
tSplash.isOfflineAd() | Is the current ad offline |
tSplash.getFillAdType() | Whether the current filled advertisement is offline or online advertising; 1: offline advertisement, 0: online advertisement, -1: no filling |