本文整理汇总了Java中com.google.android.gms.ads.InterstitialAd.setAdUnitId方法的典型用法代码示例。如果您正苦于以下问题:Java InterstitialAd.setAdUnitId方法的具体用法?Java InterstitialAd.setAdUnitId怎么用?Java InterstitialAd.setAdUnitId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.ads.InterstitialAd
的用法示例。
在下文中一共展示了InterstitialAd.setAdUnitId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showFullScreenAdsIfRequired
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的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();
}
}
});
}
示例2: setUpAds
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的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();
}
示例3: createNewIntAd
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的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;
}
示例4: onCreate
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的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();
}
});
}
示例5: request
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的package包/类
@Override
protected void request(Context context, Map<String, String> networkData) {
if (context == null || networkData == null) {
invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
} else {
String unitId = networkData.get(AdMob.KEY_UNIT_ID);
if (TextUtils.isEmpty(unitId)) {
invokeLoadFail(PNException.ADAPTER_MISSING_DATA);
} else {
mInterstitialAd = new InterstitialAd(mContext);
mInterstitialAd.setAdUnitId(unitId);
mInterstitialAd.setAdListener(mAdListener);
mInterstitialAd.loadAd(AdMob.getAdRequest(context));
}
}
}
示例6: initADs
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的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();
}
}
示例7: onCreate
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的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();
}
示例8: setUpInterstitialAd
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的package包/类
/**
* Sets up the interstitial ad object.
*/
private void setUpInterstitialAd() throws Exception {
if (!(advertable instanceof Activity)) {
throw new Exception("Only Activity class can implement HackChatInterstitialAdvertable.");
}
interstitialAd = new InterstitialAd((Activity) advertable);
interstitialAd.setAdUnitId(adUnitId);
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
advertable.onInterstitialAdClosed();
}
});
requestInterstitialAd();
}
示例9: initAdmob
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的package包/类
/**
* Ads for the app.
*/
private void initAdmob() {
int curTime = App.Instance.getAdsShownTimes();
int adsTimes = 7;
if (curTime % adsTimes == 0) {
// Create an ad.
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
// Create ad request.
AdRequest adRequest = new AdRequest.Builder().build();
// Begin loading your interstitial.
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
displayInterstitial();
}
});
mInterstitialAd.loadAd(adRequest);
}
curTime++;
App.Instance.setAdsShownTimes(curTime);
}
示例10: onCreate
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragment_location);
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getResources().getString(R.string.interstitial_ad));
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
finish();
}
});
AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
开发者ID:akashandroid90,项目名称:GooglePlayServiceLocationSupport,代码行数:19,代码来源:FragmentLocationActivity.java
示例11: handleInterstitialAd
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的package包/类
private void handleInterstitialAd() {
String adId = Preferences.getInstance(this).getAdmobInterstitialId();
if (adId == null || adId.length() == 0)
return;
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId(adId);
// Create ad request.
AdRequest adRequest = new AdRequest.Builder().build();
// Begin loading your interstitial.
interstitial.loadAd(adRequest);
interstitial.setAdListener(new AdListener() {
public void onAdLoaded() {
if (interstitial.isLoaded()) {
interstitial.show();
}
}
});
}
示例12: onCreate
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
if (mHelper == null) {
getGameHelper();
}
// Create the interstitial ad.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(getString(R.string.test_device_id))
.build();
// Begin loading the interstitial ad. It is not show until the game is isGameLost.
interstitial.loadAd(adRequest);
}
示例13: initAd
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的package包/类
public static void initAd(final Context context) {
if (isAbmobEnabled()) {
// Create the interstitial.
sInterstitialAd = new InterstitialAd(context);
sInterstitialAd.setAdUnitId(Model.getInstance().getConfiguration().getAdmobId());
// Create ad request.
final AdRequest adRequest = new AdRequest.Builder().build();
// Begin loading your interstitial.
sInterstitialAd.loadAd(adRequest);
sInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
displayInterstitial();
}
});
}
}
示例14: cacheInterstitial
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的package包/类
public void cacheInterstitial(String adID, String testDevice)
{
//Log.d("SOLITAIRE", "CACHE");
_interstitial = new InterstitialAd(_act);
_interstitial.setAdUnitId(adID);
AdRequest adRequest = null;
if(testDevice == null) //no test device
adRequest = new AdRequest.Builder().build();
else
adRequest = new AdRequest.Builder().addTestDevice(testDevice).build(); //eto pizdec
_interstitial.loadAd(adRequest);
_interstitial.setAdListener(new AdMobListener(_ctx, "INTERSTITIAL"));
}
示例15: requestAd
import com.google.android.gms.ads.InterstitialAd; //导入方法依赖的package包/类
@Override
public void requestAd(MediatedInterstitialAdViewController mIC, Activity activity,
String parameter, String adUnitId, TargetingParameters targetingParameters) {
adListener = new GooglePlayAdListener(mIC, super.getClass().getSimpleName());
adListener.printToClog(String.format(" - requesting an ad: [%s, %s]", parameter, adUnitId));
interstitialAd = new InterstitialAd(activity);
interstitialAd.setAdUnitId(adUnitId);
interstitialAd.setAdListener(adListener);
try {
interstitialAd.loadAd(buildRequest(targetingParameters));
} catch (NoClassDefFoundError e) {
// This can be thrown by Play Services on Honeycomb.
adListener.onAdFailedToLoad(AdRequest.ERROR_CODE_NO_FILL);
}
}