Search...
Menu

App Open Ads

πŸ’‘Tips

  • Automatically manages parallel loading across multiple placements, caching, and eCPM-optimized display β€” developers only need load β†’ isReady β†’ show
  • load() must be called only after MCSDK.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 onAdLoadTimeout callback β€” handle timeout logic based on your business scenario
  • show() requires a ViewGroup container to host the app open ad view

java Copy
// 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 before load(), otherwise the first loading callbacks may be missed
  • Duplicate load() calls during an ongoing loading cycle are automatically ignored β€” no manual deduplication needed
  • onAdLoadTimeout fires when loading times out β€” navigate to the main page here to avoid keeping users waiting

java Copy
// 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 ViewGroup container parameter to host the ad view
  • show() 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() returns false, the SDK automatically triggers background refill β€” you can periodically poll to check readiness

3. Resource Release

java Copy
MCSplashAdManager.getInstance().destroy();

⚠️ Note

  • Must call destroy() when Activity / Fragment is destroyed to release resources
  • After destruction, load() must be called again before further use
  • destroy() is safe to call repeatedly
  • Recommend calling container.removeAllViews() in the onAdHidden callback to clean up container views

4. Customized Parameter Configuration

java Copy
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();

Last modified: 2026-04-02Powered by