Last active
August 29, 2015 14:11
-
-
Save flurrydev/cce23ec49e88bdbdde97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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