gpt4 book ai didi

java - 如何显示视频广告 (AdColony)

转载 作者:行者123 更新时间:2023-11-30 10:28:28 25 4
gpt4 key购买 nike

我有一个应用程序,我想在其中集成来自 AdColony 的 VIDEO AD。

当用户点击按钮时,loadAd()方法被触发,之后是onRequestFilled。但是在调用 show() 之后没有任何反应。

这是包含我为 AdColony 使用的所有方法的类。

public class AdColonyAds {

private final String ZONE_ID = "vzac61b40e83e8436c9e";
private final String APP_ID_ADCOLONY = "appa567471ee29646b5b5";
private AdColonyInterstitial ad;
private AdColonyInterstitialListener listener;
private AdColonyAdOptions ad_options;
private String uniqueID;


private Activity activity;

public AdColonyAds(Activity activity) {
this.activity = activity;
uniqueID = UUID.randomUUID().toString();
}


public void initAdColony(){
AdColonyAppOptions app_options = new AdColonyAppOptions()
.setUserID(uniqueID);

AdColony.configure( activity, app_options, APP_ID_ADCOLONY, ZONE_ID );

AdColonyUserMetadata metadata = new AdColonyUserMetadata()
.setUserAge( 26 )
.setUserEducation( AdColonyUserMetadata.USER_EDUCATION_BACHELORS_DEGREE )
.setUserGender( AdColonyUserMetadata.USER_MALE );

ad_options = new AdColonyAdOptions()
.enableConfirmationDialog( true )
.enableResultsDialog( true )
.setUserMetadata( metadata );

AdColony.setRewardListener( new AdColonyRewardListener()
{
@Override
public void onReward( AdColonyReward reward )
{
reward.getRewardAmount();
}
} );

listener = new AdColonyInterstitialListener() {
@Override
public void onRequestFilled(AdColonyInterstitial adColonyInterstitial) {
Toast.makeText(activity,"Ready",Toast.LENGTH_SHORT).show();
adColonyInterstitial.show();
}
};
}

public void showAdColony(){
ad.show();
}

public void loadAd(){
AdColony.requestInterstitial( ZONE_ID, listener, ad_options );
}

最佳答案

您可能需要在 onRequestFilled 监听器中设置 ad 实例变量,以便在 showAdColony 方法之后使用。

listener = new AdColonyInterstitialListener() {
@Override
public void onRequestFilled(AdColonyInterstitial adColonyInterstitial) {
ad = adColonyInterstitial;
}
};

关于java - 如何显示视频广告 (AdColony),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44606268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com