當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。