我有一个应用程序,我想在其中集成来自AdColony的视频广告。
当用户单击按钮时,将触发 loadAd(( 方法,然后触发 requestFilled。但是在调用 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 );
}
}
您可能需要
在侦听器ad
设置实例变量onRequestFilled
以便在 from showAdColony
方法之后使用。
listener = new AdColonyInterstitialListener() {
@Override
public void onRequestFilled(AdColonyInterstitial adColonyInterstitial) {
ad = adColonyInterstitial;
}
};