π‘Tips
- Automatically manages parallel loading across multiple placements, caching, and eCPM-optimized display β developers only need
loadβisReadyβshowload()must be called only afterMCSDK.init()completes, otherwise loading silently fails- SDK auto-refills after ad close, no manual reload needed;
isReady()returning false also triggers automatic background refill- App Open Ads include an
onAdLoadTimeoutcallback β handle timeout logic based on your business scenarioshow()requires aViewGroupcontainer to host the app open ad view
// 1. Set callbacks
MCSplashAdManager.getInstance().setListener(new MCSplashAdManagerListener() {
@Override
public void onAdLoaded(MCAdInfo adInfo) {
// At least one ad is ready (triggered at most once per loading round)
}
@Override
public void onAdLoadFailed(MCError error) {
// All placements failed to load (mutually exclusive with onAdLoaded)
}
@Override
public void onAdLoadFinished() {
// All placements in this round have finished loading (fires regardless of success or failure)
}
@Override
public void onAdDisplayed(MCAdInfo adInfo) {
// Ad displayed successfully
}
@Override
public void onAdHidden(MCAdInfo adInfo) {
// Ad closed β recommend removing views from the container here
if (container != null) {
container.removeAllViews();
}
}
@Override
public void onAdClicked(MCAdInfo adInfo) {
// Ad clicked
}
@Override
public void onAdDisplayFailed(MCAdInfo adInfo, MCError error) {
// Display failed
}
@Override
public void onAdRevenuePaid(MCAdInfo adInfo) {
// Ad revenue callback (for revenue attribution)
}
// --- App Open-specific callback ---
@Override
public void onAdLoadTimeout() {
// Loading timed out β recommend navigating to the app's main page here
}
});
// 2. Load (SDK automatically manages multiple placements based on server configuration)
MCSplashAdManager.getInstance().load();
β οΈ Note
setListener()should be called beforeload(), otherwise the first loading callbacks may be missed- Duplicate
load()calls during an ongoing loading cycle are automatically ignored β no manual deduplication neededonAdLoadTimeoutfires when loading times out β navigate to the main page here to avoid keeping users waiting
// container is the parent ViewGroup for hosting the app open ad
if (MCSplashAdManager.getInstance().isReady()) {
MCSplashAdManager.getInstance().show(activity, container);
}
π‘ Note
- App Open Ads require a
ViewGroupcontainer parameter to host the ad viewshow()automatically selects the highest eCPM ad from the cache pool β no manual comparison needed- After display, the cache for that placement is consumed and the SDK auto-refills
- When
isReady()returnsfalse, the SDK automatically triggers background refill β you can periodically poll to check readiness
MCSplashAdManager.getInstance().destroy();
β οΈ Note
- Must call
destroy()when Activity / Fragment is destroyed to release resources- After destruction,
load()must be called again before further usedestroy()is safe to call repeatedly- Recommend calling
container.removeAllViews()in theonAdHiddencallback to clean up container views
Map<String, Object> loadExtraParameter = new HashMap<>();
loadExtraParameter.put("key", "value");
MCSplashAdManager.getInstance().setLoadExtraParameter(loadExtraParameter);
Map<String, String> extraParameter = new HashMap<>();
extraParameter.put("key", "value");
MCSplashAdManager.getInstance().setExtraParameter(extraParameter);
// Custom parameters must be set before load()
MCSplashAdManager.getInstance().load();