本文整理匯總了Java中com.google.android.gms.ads.InterstitialAd.loadAd方法的典型用法代碼示例。如果您正苦於以下問題:Java InterstitialAd.loadAd方法的具體用法?Java InterstitialAd.loadAd怎麽用?Java InterstitialAd.loadAd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.ads.InterstitialAd
的用法示例。
在下文中一共展示了InterstitialAd.loadAd方法的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: onCreateView
import com.google.android.gms.ads.InterstitialAd; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_cafeterias, container, false);
ButterKnife.bind(this, view);
mInterstitialAd = new InterstitialAd(getContext());
mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
AdRequest adRequest = new AdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest);
CustomListAdaptor customListAdaptor = new CustomListAdaptor(getContext(), Arrays.asList(getResources().getStringArray(R.array.cafeterias)));
lvCafeterias.setAdapter(customListAdaptor);
lvCafeterias.animate().setDuration(500);
return view;
}
示例3: 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();
}
});
}
示例4: 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));
}
}
}
示例5: 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);
}
示例6: 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
示例7: 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();
}
}
});
}
示例8: 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);
}
示例9: popUpAd
import com.google.android.gms.ads.InterstitialAd; //導入方法依賴的package包/類
public static void popUpAd(Context context) {
final InterstitialAd interstitialAd = getInstance(context);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("BE5D7D1E701EF21AB93369A353CAA3ED")
.addTestDevice("921DF5A672991967B9FFE364D0FF8498")
.addTestDevice("A642C45F5DD4C0E09AA896DDABD36789")
.addTestDevice("5270E2092AA1F46AC51964363699AB9E")
.build();
interstitialAd.loadAd(adRequest);
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
interstitialAd.show();
}
});
}
示例10: 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();
}
});
}
}
示例11: 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"));
}
示例12: 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);
}
}
示例13: requestInterstitial
import com.google.android.gms.ads.InterstitialAd; //導入方法依賴的package包/類
/**
* Shows a new interstitial.
*
* @param admobAdID Your AdMob interstitial id.
* @param activity
* @param clickCallback See {@link es.javocsoft.android.lib.toolbox.ads.InterstitialAdsListener.OnInterstitialClickCallback}
* @return
*/
public InterstitialAd requestInterstitial(String admobAdID, Activity activity, InterstitialAdsListener.OnInterstitialClickCallback clickCallback) {
Log.i(ToolBox.TAG, "Ads: Preparing a new interstitial.");
// Create the interstitial.
InterstitialAd interstitial = new InterstitialAd(activity.getApplicationContext());
interstitial.setAdUnitId(admobAdID);
AdRequest adRequest = interstitialAdRequest(interstitial, activity);
if(adRequest!=null) {
interstitial.loadAd(adRequest);
interstitial.setAdListener(new InterstitialAdsListener(interstitial, clickCallback));
}
return interstitial;
}
示例14: initAds
import com.google.android.gms.ads.InterstitialAd; //導入方法依賴的package包/類
private void initAds() {
MobileAds.initialize(this, "ca-app-pub-2757743767659351~9555852028");
//MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713"); // Test
bigAd = new InterstitialAd(this);
bigAd.setAdUnitId("ca-app-pub-2757743767659351/2179020563");
bigAd.loadAd(new AdRequest.Builder().build());
adTop = findViewById(R.id.adViewTop);
adBottom = findViewById(R.id.adViewBottom);
adBottom.loadAd(new AdRequest.Builder().build());
adTop.loadAd(new AdRequest.Builder().build());
}
示例15: onCreate
import com.google.android.gms.ads.InterstitialAd; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_result);
sp = PreferenceManager.getDefaultSharedPreferences(this);
adView = (AdView) findViewById(R.id.avViewr);
tv1 = (TextView) findViewById(R.id.tv1);
tv2 = (TextView) findViewById(R.id.tv2);
tv3 = (TextView) findViewById(R.id.tv3);
Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
toolbar.setTitle("Result");
setSupportActionBar(toolbar);
displayAnswer1();
displayAnswer2();
displayAnswer3();
initAds();
mInterAd = new InterstitialAd(this);
mInterAd.setAdUnitId(getResources().getString(R.string.finish_inter_ad_id));
mInterAd.loadAd(new AdRequest.Builder().build());
mInterAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
finish();
}
});
}