Skip to content

Instantly share code, notes, and snippets.

@flurrydev
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flurrydev/cce23ec49e88bdbdde97 to your computer and use it in GitHub Desktop.
Save flurrydev/cce23ec49e88bdbdde97 to your computer and use it in GitHub Desktop.
import com.flurry.android.ads.FlurryAdInterstitial;
import com.flurry.android.ads.FlurryAdInterstitialListener;
public class Example extends Activity {
FlurryAdInterstitialListener interstitialAdListener = new FlurryAdInterstitialListener() {
@Override
public void onFetched(FlurryAdInterstitial adInterstitial) {
adInterstitial.displayAd();
}
@Override
public void onError(FlurryAdInterstitial adInterstitial, FlurryAdErrorType adErrorType, int errorCode) {
adInterstitial.destroy();
}
//..
//the remainder of listener callbacks
};
private FlurryAdInterstitial mFlurryAdInterstitial = null;
private String mAdSpaceName = "INTERSTITIAL_ADSPACE";
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.example);
mFlurryAdInterstitial = new FlurryAdInterstitial(this, mAdSpaceName);
// allow us to get callbacks for ad events
mFlurryAdInterstitial.setListener(interstitialAdListener);
}
public void onStart() {
super.onStart();
FlurryAgent.onStartSession(this, mApiKey);
// fetch and prepare ad for this ad space. won’t render one yet
mFlurryAdInterstitial.fetchAd();
}
public void onStop() {
FlurryAgent.onEndSession(this);
//do NOT call mFlurryAdInterstitial.destroy() here.
//it will destroy the object prematurely and prevent certain listener callbacks form fireing
super.onStop();
}
public void onDestroy() {
mFlurryAdInterstitial.destroy();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment