Examples
Set up a banner ad using the ‘adLoaded’ callback
This example demonstrates how to set up a banner ad with the Bumper page enabled, and display the ad as soon as it loads.
<tv.superawesome.sdk.publisher.SABannerAd
android:id="@+id/mybanner"
android:layout_width="match_parent"
android:layout_height="100dp"/>
import tv.superawesome.sdk.publisher.*;
public class MainActivity extends Activity {
private SABannerAd banner = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get the banner
bannerAd = (SABannerAd) findViewById(R.id.mybanner);
// set up the Bumper page on the banner ad (optional)
bannerAd.enableBumperPage();
// add a callback
bannerAd.setListener(new SAInterface() {
@Override
public void onEvent(int placementId, SAEvent event) {
if (event == SAEvent.adLoaded) {
bannerAd.play(MainActivity.this);
}
}
});
// start the loading process
bannerAd.load(30471);
}
}
import tv.superawesome.sdk.publisher.*;
class MainActivity : Activity() {
private lateinit var banner: SABannerAd
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// get the banner
bannerAd = findViewById<SABannerAd>(R.id.mybanner)
// set up the Bumper page on the banner ad (optional)
bannerAd.enableBumperPage()
// add a callback
bannerAd.setListener { placementId, event ->
if (event == SAEvent.adLoaded) {
bannerAd.play(this@MainActivity)
}
}
// start the loading process
bannerAd.load(30471)
}
}
Set up multiple ads using the ‘HasAdAvailable’ method
This example demonstrates how to set up and display:
- a banner ad with the Parental Gate enabled.
- multiple video ads with the Bumper page enabled.
import tv.superawesome.sdk.publisher.*;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get the banner
bannerAd = (SABannerAd) findViewById(R.id.mybanner);
// set up the Parental Gate on the banner (optional)
bannerAd.enableParentalGate();
// load the banner ad
bannerAd.load(30471);
// display the Bumper page on the video ad
SAVideoAd.enableBumperPage();
// disable the close button so the user has to watch
// the video through to the end
SAVideoAd.disableCloseButton();
// load the video
SAVideoAd.load(30479, MainActivity.this);
SAVideoAd.load(30480, MainActivity.this);
}
public void playBanner(View view) {
if (banner.hasAdAvailable()) {
banner.play(MainActivity.this);
}
}
public void playVideo1(View view) {
if (SAVideoAd.hasAdAvailable(30479)) {
// set the orientation in which the video will play
SAVideoAd.setOrientationLandscape();
// and play the video
SAVideoAd.play(30479, MainActivity.this);
}
}
public void playVideo2(View view) {
if (SAVideoAd.hasAdAvailable(30480)) {
// set the orientation in which the video will play
SAVideoAd.setOrientationAny();
// and play the video
SAVideoAd.play(30480, MainActivity.this);
}
}
}
import tv.superawesome.sdk.publisher.*;
class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get the banner
bannerAd = findViewById<SABannerAd>(R.id.mybanner);
// set up the Parental Gate on the banner (optional)
bannerAd.enableParentalGate()
// load the banner ad
bannerAd.load(30471)
// display the Bumper page on the video ad
SAVideoAd.enableBumperPage()
// disable the close button so the user has to watch
// the video through to the end
SAVideoAd.disableCloseButton()
// load the video
SAVideoAd.load(30479, this);
SAVideoAd.load(30480, this);
}
fun playBanner() {
if (banner.hasAdAvailable()) {
banner.play(this);
}
}
fun playVideo1() {
if (SAVideoAd.hasAdAvailable(30479)) {
// set the orientation in which the video will play
SAVideoAd.setOrientationLandscape()
// and play the video
SAVideoAd.play(30479, this)
}
}
fun playVideo2() {
if (SAVideoAd.hasAdAvailable(30480)) {
// set the orientation in which the video will play
SAVideoAd.setOrientationAny()
// and play the video
SAVideoAd.play(30480, this)
}
}
}