Skip to content

Instantly share code, notes, and snippets.

@Bisera
Last active December 17, 2015 23:29
Show Gist options
  • Save Bisera/5689317 to your computer and use it in GitHub Desktop.
Save Bisera/5689317 to your computer and use it in GitHub Desktop.
import com.flurry.android.FlurryAds;
import com.flurry.android.FlurryAdSize;
import com.flurry.android.FlurryAgent;
import com.flurry.android.FlurryAdListener;
public class BannerAdsActivity extends Activity implements FlurryAdListener {
FrameLayout mBanner;
private String adSpace="MediatedBannerBottom";
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
mBanner = (FrameLayout)findViewById(R.id.banner);
}
@Override
public void onStart() {
super.onStart();
FlurryAgent.onStartSession(this, mApiKey);
// get callbacks for ad events
FlurryAds.setAdListener(this);
// fetch and prepare ad for this ad space. won’t render one yet
FlurryAds.fetchAd(this, adSpace, mBanner, FlurryAdSize.BANNER_BOTTOM);
}
@Override
public void spaceDidReceiveAd(String adSpace) {
// called when the ad has been prepared, ad can be displayed:
FlurryAds.displayAd(this, adSpace, mBanner);
// instead of displaying the ad here, you can check
// FlurryAds.isAdReady(adSpace)
// and display the ad when ready to do so in your Activity.
}
@Override
public boolean shouldDisplayAd(String adSpace, FlurryAdType arg1) {
//verify this method returns true to display the fetched ad
return true;
}
@Override
public void onStop() {
super.onStop();
FlurryAds.removeAd(this, adSpace, mBanner);
FlurryAgent.onEndSession(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment