Created
October 26, 2021 11:31
-
-
Save omkar-tenkale/28aea097e685ffbb3d7acef744a0609f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseActivity extends FragmentActivity { | |
@Override | |
protected void onCreate(@Nullable Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
IronSource.init(this, AppConfig.IRONSOURCE_APP_KEY); | |
... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends BaseActivity { | |
IronSourceBannerLayout banner; | |
LinearLayout adContainer; | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
initAd(); | |
} | |
private void initAd() { | |
if(banner==null) { | |
banner = IronSource.createBanner(this, ISBannerSize.BANNER); | |
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); | |
adContainer = findViewById(R.id.banner_container); | |
adContainer.addView(banner, 0, layoutParams); | |
} | |
banner.setBannerListener(new BannerListener() { | |
@Override | |
public void onBannerAdLoaded() { | |
Log.oneLine("Called after a banner ad has been successfully loaded"); | |
} | |
@Override | |
public void onBannerAdLoadFailed(IronSourceError error) { | |
Log.oneLine("// Called after a banner has attempted to load an ad but failed.: "+error.getErrorCode()+" "+error.getErrorMessage()); | |
runOnUiThread(() -> adContainer.removeAllViews()); | |
} | |
@Override | |
public void onBannerAdClicked() { | |
Log.oneLine("// Called after a banner has been clicked."); | |
} | |
@Override | |
public void onBannerAdScreenPresented() { | |
Log.oneLine("// // Called when a banner is about to present a full screen content."); | |
} | |
@Override | |
public void onBannerAdScreenDismissed() { | |
Log.oneLine("// // Called after a full screen content has been dismissed."); | |
} | |
@Override | |
public void onBannerAdLeftApplication() { | |
Log.oneLine("// Called when a user would be taken out of the application context."); | |
} | |
}); | |
IronSource.loadBanner(banner); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment