本文整理汇总了Java中com.google.android.gms.ads.AdListener类的典型用法代码示例。如果您正苦于以下问题:Java AdListener类的具体用法?Java AdListener怎么用?Java AdListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AdListener类属于com.google.android.gms.ads包,在下文中一共展示了AdListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gotoMenu
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
private void gotoMenu(Context context) {
timer.cancel();
// Save highscore
SharedPreferences prefs = context.getSharedPreferences(MainActivity.class.getSimpleName(), MODE_PRIVATE);
int highscore = Math.max(prefs.getInt("highscore", 0), game.getScore());
SharedPreferences.Editor edit = prefs.edit();
edit.putInt("highscore", highscore);
edit.apply();
Intent goBack = new Intent(context, MainActivity.class);
goBack.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (random.nextBoolean()) {
bigAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
context.startActivity(goBack);
}
});
bigAd.show();
} else {
context.startActivity(goBack);
}
}
示例2: initializeAds
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
public static void initializeAds(Context context, View bannerPlaceholder, NativeExpressAdView adView, AnalyticsHelper analyticsHelper, String screenName) {
initializeAds(context, adView);
adView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
apply(bannerPlaceholder, GONE);
apply(adView, VISIBLE);
}
@Override
public void onAdFailedToLoad(int i) {
analyticsHelper.logScreenEvent(screenName, AD_FAILED_TO_LOAD);
}
@Override
public void onAdClicked() {
analyticsHelper.logScreenEvent(screenName, AD_CLICKED);
}
});
}
示例3: showFullScreenAdsIfRequired
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
public static void showFullScreenAdsIfRequired(final StateActivity activity) {
if (Premium.isPremiumUser(activity)) return;
final InterstitialAd interstitialAd = new InterstitialAd(activity.getApplicationContext());
interstitialAd.setAdUnitId(AdConstants.AdUnitId.AD_UNIT_ID_INTERSTITIAL);
AdRequest.Builder request = new AdRequest.Builder();
if (BuildConfig.DEBUG) {
request.addTestDevice(TEST_DEVICE_ID);
}
interstitialAd.loadAd(request.build());
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
if (!activity.isFinishing() && activity.isActivityVisible()) {
interstitialAd.show();
}
}
});
}
示例4: onBackPressed
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
@Override
public void onBackPressed() {
if (BuildConfig.IS_PREMIUM_USER) {
super.onBackPressed();
return;
}
if (interstitialAd != null) {
if (interstitialAd.isLoaded()) {
interstitialAd.show();
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
finish();
}
});
} else {
super.onBackPressed();
}
}
}
示例5: createNewIntAd
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
private InterstitialAd createNewIntAd() {
InterstitialAd intAd = new InterstitialAd(context);
intAd.setAdUnitId(context.getString(R.string.tip_click_int_ad_id));
intAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
}
@Override
public void onAdFailedToLoad(int errorCode) {
}
@Override
public void onAdClosed() {
// Proceed to the next level.
//levelTwo();
}
});
return intAd;
}
示例6: onCreate
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
mInterstitialAd = new InterstitialAd(this);
// set the ad unit ID
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("DCAB007CDB3101E631F092966F546CC2")
.build();
// Load ads into Interstitial Ads
mInterstitialAd.loadAd(adRequest);
mInterstitialAd.setAdListener(new AdListener() {
public void onAdLoaded() {
showInterstitial();
}
});
}
示例7: setUpAds
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
private void setUpAds() {
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
interstitialAd = new InterstitialAd(getContext());
interstitialAd.setAdUnitId(interstitialAdUnitId);
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(int i) {
super.onAdFailedToLoad(i);
requestNewInterstitial();
}
@Override
public void onAdClosed() {
super.onAdClosed();
requestNewInterstitial();
}
@Override
public void onAdOpened() {
super.onAdOpened();
requestNewInterstitial();
}
});
requestNewInterstitial();
}
示例8: AdViewIdlingResource
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
public AdViewIdlingResource(AdView adView) {
if (adView == null) {
throw new IllegalArgumentException(
"Can't initialize AdViewIdlingResource with null AdView.");
}
this.mAdView = adView;
this.mAdListener = new AdListener() {
@Override
public void onAdFailedToLoad(int i) {
transitionToIdle();
}
@Override
public void onAdLoaded() {
transitionToIdle();
}
};
mAdView.setAdListener(mAdListener);
}
示例9: fetchAd
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
@Override
public void fetchAd() {
new AdLoader.Builder(this.getContext(), this.adUnitId)
.forAppInstallAd(AdMobNativeAd.this)
.forContentAd(AdMobNativeAd.this)
.withNativeAdOptions(this.getNativeAdOptionsBuilder().build())
.withAdListener(new AdListener() {
@Override
public void onAdOpened() {
AdMobNativeAd.this.notifyAdClicked();
}
@Override
public void onAdFailedToLoad(final int errorCode) {
AdMobNativeAd.this.onAdFailedToLoad(errorCode);
}
})
.build()
.loadAd(this.getAdRequestBuilder().build());
}
示例10: setupTabInterstitialsAd
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
private void setupTabInterstitialsAd() {
String[] ids = getResources().getStringArray(R.array.tabs_interstitials_id);
for (int i = 0; i < interstitialsTabAd.length; i++) {
if (!interstitialIsReady(interstitialsTabAd[i])) {
final int finalI = i;
AdListener adListener = new AdListener() {
@Override public void onAdClosed() {
super.onAdClosed();
interstitialsTabAd[finalI] = null;
setupTabInterstitialsAd();
}
};
interstitialsTabAd[i] = newInterstitialAd(ids[i], adListener);
}
}
}
示例11: setupSettingsInterstitialsAd
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
private void setupSettingsInterstitialsAd() {
String[] ids = getResources().getStringArray(R.array.settings_interstitials_id);
for (int i = 0; i < interstitialsSettingsAd.length; i++) {
if (!interstitialIsReady(interstitialsSettingsAd[i])) {
final int finalI = i;
AdListener adListener = new AdListener() {
@Override public void onAdClosed() {
super.onAdClosed();
interstitialsSettingsAd[finalI] = null;
setupSettingsInterstitialsAd();
startActivity(new Intent(MainActivity.this, SettingsActivity.class));
}
};
interstitialsSettingsAd[i] = newInterstitialAd(ids[i], adListener);
}
}
}
示例12: setupInstallInterstitialsAd
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
private void setupInstallInterstitialsAd() {
String[] ids = getResources().getStringArray(R.array.install_interstitials_id);
for (int i = 0; i < interstitialsInstallAd.length; i++) {
if (!interstitialIsReady(interstitialsInstallAd[i])) {
final int finalI = i;
AdListener adListener = new AdListener() {
@Override public void onAdClosed() {
super.onAdClosed();
interstitialsInstallAd[finalI] = null;
setupInstallInterstitialsAd();
}
};
interstitialsInstallAd[i] = newInterstitialAd(ids[i], adListener);
}
}
}
示例13: initADs
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
void initADs() {
if(enableADs) {
//https://firebase.google.com/docs/admob/android/quick-start
MobileAds.initialize(getApplicationContext(), getString(R.string.ad_app_id));
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Log.d(LOG_TAG, "Ads initialized..");
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
//requestNewInterstitial();
}
});
requestNewInterstitial();
}
}
示例14: onActivityCreated
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (!SPUtils.getBoolean(mActivity, "User", "google", false)) {
mCircleImageView.setOnClickListener(this);
mNickname.setOnClickListener(this);
setHasOptionsMenu(true);
}
mAdView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
CircularRevealUtils.show(mAdView);
}
});
}
示例15: onCreate
import com.google.android.gms.ads.AdListener; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mInterstitialAd = new InterstitialAd(getActivity());
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
requestNewInterstitial();
openJokeActivity();
}
});
requestNewInterstitial();
}