Video Ads

The following code block sets up a video ad and loads it:

public class MainActivity extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        setContentView (R.layout.activity_main);

        // to display test ads
        SAVideoAd.enableTestMode ();

        // set configuration to production
        SAVideoAd.setConfigurationProduction ();

        // lock orientation to portrait or landscape
        SAVideoAd.setOrientationLandscape ();

        // enable or disable the android back button
        SAVideoAd.enableBackButton ();

        // enable or disable a close button
        SAVideoAd.enableCloseButton ();

        // enable or disable a close button that displays without a delay. Use instead of enableCloseButton.
        // WARNING: this will allow users to close the ad before the viewable tracking event is fired
        // and should only be used if you explicitly want this behaviour over consistent tracking.
        // enable close button and warn user before closing

        // enable or disable auto-closing at the end
        SAVideoAd.disableCloseAtEnd ();

        // make the whole video surface area clickable
        SAVideoAd.disableSmallClickButton ();
        // mute the video on start
        SAVideoAd.enableMuteOnStart ();

        // start loading ad data for a placement
        SAVideoAd.load (30479, MainActivity.this);

Once you’ve loaded an ad, you can also display it:

public void onClick (View view) {

    // check if ad is loaded
    if (SAVideoAd.hasAdAvailable (30479)) {

        // display the ad (30479, MainActivity.this);

These are the default values:

Parameter Value
Configuration Production
Test mode Disabled
Orientation Any
Closes at end True
Close button Disabled
Small click button Disabled
Back button Disabled
Close button with no delay Disabled
Close with warning Disabled
Mute on start Disabled