Java Question Variable from another Class

Johnmcenroy

Active Member
Licensed User
Longtime User
I have two classes in the same package
First:

B4X:
public class MoPubLibFull extends ViewWrapper<MoPubView> {
   
   /**
    * // Enter your TapForTap API
    */
   
   public void InitialiseTapForTap (BA ba , String TapAPI)
   {
     String [B]TapAPIba[/B] = TapAPI;
   }
}


Second
B4X:
public class TapForTapBanner extends CustomEventBanner implements com.tapfortap.AdView.AdViewListener {
  private com.tapfortap.AdView tapForTapAdView;
   private CustomEventBannerListener customEventBannerListener;
   
   @Override
   public void loadBanner(Context context, CustomEventBannerListener customEventBannerListener, Map<String, Object> localExtras,
         Map<String, String> serverExtras) {
      this.customEventBannerListener = customEventBannerListener;
      if (tapForTapAdView == null) {
       TapForTap.initialize(context, [B]TapAPIba FROM FIRST CLASS[/B] );
       tapForTapAdView = new com.tapfortap.AdView(context);
       tapForTapAdView.autoRollover = false;
       tapForTapAdView.setListener(this);
      }
      tapForTapAdView.loadAds();
 
   }

How to get variable TapAPIba from FIRST CLASS ?

Thanks
 
Last edited:

NFOBoy

Active Member
Licensed User
Longtime User
You could add an initialize method for the TapForTapBanner, and pass in what you need
 

Johnmcenroy

Active Member
Licensed User
Longtime User
Thank you fo reply. Didn't think about that. But I don't want to initialize TapForTap I only want to set a variable from B4A and then when TapForTap loaded it will pick up this variable. The problem is that TapForTap is a Custom Event Class for MoPub. So I initialize MoPub and then if I added TapForTap in my MoPub web interface MoPub will load this TapForTap class.
 
Last edited:

Johnmcenroy

Active Member
Licensed User
Longtime User
I made a simple class to share special global variables.

B4X:
package com.mopub.mobileads;

public class Global {

public static String TapAPIba;
}


So I can use everywhere by typing Global.TapAPIba which I pass to SDK from B4A.
stackoverflow.com/questions/4646577/global-variables-in-java

Works fine.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…