I am trying to implement Smaato Video Ads on my Android App. I have followed the instructions from the Smaato page and the Smaato example app and yet, I cannot manage to show the Smaato Video Ads. The code that apparently should show a video ad in fullscreen is:
private static Video smaatoVideoAd; // A Smaato Video global variable
smaatoVideoAd = new Video(this.getApplicationContext());
smaatoVideoAd.getAdSettings().setPublisherId(0); //int of 0 is supposedly a test mode
//smaatoVideoAd.getAdSettings().setPublisherId(PublisherID);
smaatoVideoAd.getAdSettings().setAdspaceId(0); //int of 0 is supposedly a test mode
//smaatoVideoAd.getAdSettings().setAdspaceId(VideoAd_ID);
smaatoVideoAd.setVastAdListener(this);
smaatoVideoAd.setAutoCloseDuration(5);
smaatoVideoAd.disableAutoClose(true);
smaatoVideoAd.setVideoSkipInterval(3);
} // End of onCreate
// Called when the video has been loaded.
@Override
public void onReadyToShow() {
// Call this when you want to show the video ad.
smaatoVideoAd.show();
}
@Override
public void onWillShow() {
// Called when the ad will show.
}
@Override
public void onWillOpenLandingPage() {
// Called when the banner has been clicked.
}
@Override
public void onWillClose() {
// Called when Interstitial ad will be closed.
}
@Override
public void onFailedToLoadAd() {
// called when video failed to load.
}
The Smaato libs for build.gradle has been setup, and that is pretty straightforward and short:
repositories {
...
flatDir {
dirs 'libs'
}
...
}
dependencies {
...
implementation name:'SOMAAndroid-9.1.3-release', ext:'aar'
...
}
And in the AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-feature android:name="android.hardware.location.network" />
<meta-data android:name=”com.google.android.gms.version” android:value=”@integer/google_play_services_version”/>
<activity android:name="com.smaato.soma.interstitial.InterstitialActivity" android:resizeableActivity="false" android:screenOrientation="landscape" />
<activity android:name="com.smaato.soma.video.VASTAdActivity" android:resizeableActivity="false" android:screenOrientation="landscape" />
<activity android:name="com.smaato.soma.ExpandedBannerActivity" android:resizeableActivity="false" android:screenOrientation="landscape" />
Besides, Smaato declares that: "Since v8.0.0, the Smaato Android SDK contains an automatic initialization routine. Therefore there is no need for publishers to manually call an additional SDK initialization method".
But running this code, gives me the following alert in the Logcat:
SOMA_VIDEO: Video must be loaded before showing it
So, the video add is not loading at all. What am I missing here? Can you help me? Thanks.
Solved! Apparently, I hadn't the correct sequence order. With this order, the warning in Logcat vanishes:
Notice that the code for Smaato video ad in trial mode is 3090, not 0. Also, I have put the Smaato Ad in a new activity, so closing the ad will close the child activity and not my main one.