当前位置: 首页>>代码示例>>Java>>正文


Java AdListener类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:pontusstjerna,项目名称:SnakeWear,代码行数:26,代码来源:Game.java

示例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);
        }
    });
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:22,代码来源:Ads.java

示例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();
            }
        }
    });
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:20,代码来源:AdsManager.java

示例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();
        }
    }
}
 
开发者ID:tranleduy2000,项目名称:ascii_generate,代码行数:22,代码来源:MainActivity.java

示例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;
}
 
开发者ID:shivam301296,项目名称:True-Weather,代码行数:23,代码来源:AdBhai.java

示例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();
        }
    });
}
 
开发者ID:anwarcse12028,项目名称:Ad-Mob,代码行数:23,代码来源:SecondActivity.java

示例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();
}
 
开发者ID:Protino,项目名称:Build-it-Bigger,代码行数:27,代码来源:MainFragment.java

示例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);
}
 
开发者ID:firebase,项目名称:quickstart-android,代码行数:22,代码来源:AdViewIdlingResource.java

示例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());
}
 
开发者ID:ayltai,项目名称:mopub-nativead-adapters,代码行数:21,代码来源:AdMobNativeAd.java

示例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);
        }
    }
}
 
开发者ID:jrummyapps,项目名称:BusyBox,代码行数:20,代码来源:MainActivity.java

示例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);
        }
    }
}
 
开发者ID:jrummyapps,项目名称:BusyBox,代码行数:21,代码来源:MainActivity.java

示例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);
        }
    }
}
 
开发者ID:jrummyapps,项目名称:BusyBox,代码行数:20,代码来源:MainActivity.java

示例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();
		}
	}
 
开发者ID:GokulNC,项目名称:USB_Mass_Storage_Enabler,代码行数:23,代码来源:MainActivity.java

示例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);
        }
    });
}
 
开发者ID:Art2Cat,项目名称:MoonlightNote,代码行数:18,代码来源:UserFragment.java

示例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();
}
 
开发者ID:frank-tan,项目名称:BuildItBigger,代码行数:18,代码来源:MainActivityFragment.java


注:本文中的com.google.android.gms.ads.AdListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。