【问题标题】:Cannot show video ads from Smaato Ads for my Android App无法为我的 Android 应用显示来自 Smaato Ads 的视频广告
【发布时间】:2019-01-12 04:24:13
【问题描述】:

我正在尝试在我的 Android 应用上实施 Smaato 视频广告。 我已按照 Smaato 页面和 Smaato 示例应用程序的说明进行操作,但我无法展示 Smaato 视频广告。 显然应该全屏显示视频广告的代码是:

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.
}

已设置好 build.gradle 的 Smaato 库,这非常简单明了:

 repositories {
 ...
     flatDir {
         dirs 'libs'
     }
 ...
 }

 dependencies {
 ...
     implementation name:'SOMAAndroid-9.1.3-release', ext:'aar'
 ...
 }

并且在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" />

此外,Smaato 声明:“自 v8.0.0 起,Smaato Android SDK 包含自动初始化例程。因此发布者无需手动调用额外的 SDK 初始化方法”。

但是运行这段代码,在 Logcat 中给了我以下警报:

SOMA_VIDEO:视频必须先加载后才能显示

因此,视频添加根本没有加载。我在这里想念什么? 你能帮助我吗?谢谢。

【问题讨论】:

    标签: android ads smaato


    【解决方案1】:

    解决了!显然,我没有正确的顺序。使用此命令,Logcat 中的警告消失:

        smaatoVideoAd = new Video(this.getApplicationContext());
        smaatoVideoAd.setVastAdListener(this);
        smaatoVideoAd.setAutoCloseDuration(3);
        smaatoVideoAd.disableAutoClose(false);
        smaatoVideoAd.setVideoSkipInterval(1);
    
        smaatoVideoAd.getAdSettings().setPublisherId(0); // Trial Publisher Id: 0
        smaatoVideoAd.getAdSettings().setAdspaceId(3090); // Trial Adspace Id for video: 3090
        smaatoVideoAd.asyncLoadNewBanner();
    

    请注意,试用模式下 Smaato 视频广告的代码是 3090,而不是 0。另外,我已将 Smaato 广告放入一个新活动中,因此关闭广告将关闭子活动,而不是我的主要活动。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-08
      相关资源
      最近更新 更多