本文整理匯總了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();
}