Ad Colony Ads Only Run Once

Problem: whenever I run the application on a new mobile device, my ad loads and works fine where I want to run it. But after that, the same mobile advertising video does not play even after I install my application again and install it.

I don’t want to show ads in my main activity, but I want to load ads into this activity. That's why I added this to my main activity class

implements AdColonyAdListener, AdColonyAdAvailabilityListener

and override its methods as follows.

    @Override
public void onAdColonyAdAvailabilityChange(boolean isAvailable, String arg1) {
    AdColonyHelper.isAdvAvailable = isAvailable;
}

@Override
public void onAdColonyAdAttemptFinished(AdColonyAd arg0) {

}

@Override
public void onAdColonyAdStarted(AdColonyAd arg0) {

}

To track ad availability, I have a static boolean in my AdColonyHelper class. AdColony Helper Class:

package Helpers;
import android.app.Activity;
import com.jirbo.adcolony.AdColonyAdListener;
import com.jirbo.adcolony.AdColonyVideoAd;

public class AdColonyHelper {
public static boolean isAdvAvailable = false;   
public static String APP_ID;
public static String ZONE_ID;

static Activity act = new Activity();

public static void setting(String appid, String zoneId, Activity myAct)
{
    APP_ID  = appid;
    ZONE_ID = zoneId;
    act = myAct;
}

public static void showAdv(boolean isAvailable)
{
    isAdvAvailable = isAvailable;
    if(isAdvAvailable)
    {
        AdColonyVideoAd ad = new AdColonyVideoAd(ZONE_ID);//.withListener( (AdColonyAdListener) act );
        ad.show();
    }
}

public static void showAdv()
{       
    if(isAdvAvailable)
    {
        AdColonyVideoAd ad = new AdColonyVideoAd(ZONE_ID).withListener( (AdColonyAdListener) act );
        ad.show();
    }
}

}

in when creating my main activity, I initialize it as follows

AdColony.configure( this, "version:1.0,store:google", APP_ID, ZONE_ID );       
    AdColony.addAdAvailabilityListener(this);       
    if ( !AdColony.isTablet() )
    {
      setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );
    }
    // below line is to set static variables in class
    AdColonyHelper.setting(APP_ID, ZONE_ID, this);

, . . .

    AdColonyHelper.showAdv();

. . logcat

01-08 14:12:15.579: I/AdColony(23623): Finished downloading: 01-08 14:12:15.609: I/AdColony(23623): https://androidads21.adcolony.com/configure?......

+4

Source: https://habr.com/ru/post/1570444/


All Articles