4

Problem : Whenever I run application on a new mobile, my ad loads and runs perfectly where I want it to run. But after that on same mobile ad video doesn't play, even after I un-install my application and install again.

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

implements AdColonyAdListener, AdColonyAdAvailabilityListener

and override its methods like this.

    @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 the availability of ad I have a static boolean variable 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 on create of my main activity I initialize it like this

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);

This is all what I have done for ads in my main activity. Now right after going to my second Activity. I have this in on create method of that activity.

    AdColonyHelper.showAdv();

This checks the availability of ad and plays it. But it plays ad just only one time. But I continuously see this in my 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?......

Yawar
  • 1,924
  • 3
  • 29
  • 39

0 Answers0