Java Question Event from another activity

Johnmcenroy

Active Member
Licensed User
Longtime User
I have the following code:
B4X:
public class Interstitial extends Activity implements InterstitialAdListener{
  
    private BA ba;
    private String eventName;
    private MoPubInterstitial mInterstitial;
    public void InitializeMopub_Interstitial(final BA ba, String EventName , String MoPub_AdUnitID )
      {
      
        mInterstitial = new MoPubInterstitial(ba.activity, MoPub_AdUnitID);
        this.ba = ba;
        this.eventName = EventName.toLowerCase(BA.cul);
        this.mInterstitial.setInterstitialAdListener(this);
  }


    @Override
    public void onInterstitialLoaded(MoPubInterstitial arg0) {
        // TODO Auto-generated method stub
        ba.raiseEvent(this, this.eventName + "_mopub_interstitial_loaded", new Object[0]);
      
    }

    @Override
    public void onInterstitialShown(MoPubInterstitial arg0) {
        // TODO Auto-generated method stub
        ba.raiseEvent(this, this.eventName + "_mopub_interstitial_shown", new Object[0]);
      
    }
  
    /**
     * Preload Mopub interstitial
     */
    public void PreloadMopub_Interstitial () {
        mInterstitial.load();
    }
  
    /**
     * Shows Mopub interstitial
     */
    public void ShowMopub_Interstitial () {
      if (mInterstitial != null) {   
        if (mInterstitial.isReady()) {
            mInterstitial.show();
        }
      }
    }
  
}

onInterstitialLoaded works well in B4A but onInterstitialShown don't and I see only in logs:
ignoring event: interstitial_mopub_interstitial_shown
How I understand it is because interstitial is in another activity ? How to make it working ?

UPDATE: Found faster that recieve answer :) Need to use raiseEvent2

Thanks
 
Last edited:
Top