本文整理汇总了Java中com.google.android.gms.ads.NativeExpressAdView.loadAd方法的典型用法代码示例。如果您正苦于以下问题:Java NativeExpressAdView.loadAd方法的具体用法?Java NativeExpressAdView.loadAd怎么用?Java NativeExpressAdView.loadAd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.ads.NativeExpressAdView
的用法示例。
在下文中一共展示了NativeExpressAdView.loadAd方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AdViewHolder
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
public AdViewHolder(View v ) {
super(v);
AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
NativeExpressAdView adView = new NativeExpressAdView(v.getContext());
adView.setAdSize(new AdSize(AdSize.FULL_WIDTH, 80));
// Load ad type based on theme - dark or light
if (PreferenceManager.getDefaultSharedPreferences(v.getContext())
.getBoolean(PREF_DARK_THEME, false)) {
adView.setAdUnitId(DARK_AD_ID);
} else {
adView.setAdUnitId(LIGHT_AD_ID);
}
((LinearLayout) v).addView(adView, 1);
adView.loadAd(request);
}
示例2: request
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的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 {
mIsImpressionConfirmed = false;
mIsReady = false;
mAdView = null;
mNativeAd = new NativeExpressAdView(mContext);
mNativeAd.setAdSize(new AdSize(WIDTH,HEIGHT));
mNativeAd.setAdUnitId(unitId);
mNativeAd.setAdListener(mAdListener);
mNativeAd.loadAd(AdMob.getAdRequest(context));
}
}
}
示例3: request
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的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 {
mIsReady = false;
mAdView = null;
mIsImpressionConfirmed = false;
mNativeAd = new NativeExpressAdView(mContext);
mNativeAd.setAdSize(AdSize.MEDIUM_RECTANGLE);
mNativeAd.setAdUnitId(unitId);
mNativeAd.setAdListener(mAdListener);
mNativeAd.loadAd(AdMob.getAdRequest(context));
}
}
}
示例4: onCreateView
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_slash, container, false);
// initialize Admob
MobileAds.initialize(mActivity, APP_ID);
NativeExpressAdView adView = view.findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder()
// .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
// .addTestDevice("0ACA1878D607E6C4360F91E0A0379C2F")
// .addTestDevice("4DA2263EDB49C1F2C00F9D130B823096")
.build();
adView.loadAd(request);
if (!adView.isLoading()) {
adView.setVisibility(View.GONE);
}
return view;
}
示例5: initializeAds
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
public static void initializeAds(Context context, NativeExpressAdView adView) {
MobileAds.initialize(context, "ca-app-pub-8963908741443055~4285788324");
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators
.addTestDevice("EF67DDDDDDD0896B1B02876D927AC309") // An example device ID
.build();
Log.d("initializeAds: ", adView.getAdUnitId());
adView.loadAd(adRequest);
}
示例6: loadAdView
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
private void loadAdView() {
if (BuildConfig.IS_PREMIUM_USER || hasPremiumApp()) {
findViewById(R.id.card_ad_view).setVisibility(View.GONE);
findViewById(R.id.btn_remove_ads).setVisibility(View.GONE);
return;
}
mAdView = (NativeExpressAdView) findViewById(R.id.native_ad_view);
if (mAdView != null) {
mAdView.loadAd(new AdRequest.Builder().build());
}
}
示例7: loadNativeAd
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
protected void loadNativeAd() {
try {
mNativeExpressAdView = (NativeExpressAdView) findViewById(R.id.native_ad_view);
if (mNativeExpressAdView != null) {
if (BuildConfig.IS_PREMIUM_USER) {
mNativeExpressAdView.setVisibility(View.GONE);
} else {
mNativeExpressAdView.loadAd(new AdRequest.Builder().build());
}
}
} catch (Exception e) {
}
}
示例8: request
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的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 {
mIsImpressionConfirmed = false;
mAdView = null;
mNativeAd = new NativeExpressAdView(mContext);
DisplayMetrics displayMetrics = new DisplayMetrics();
if(context instanceof Activity) {
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int heightDP = PNDeviceUtils.convertPxToDp(displayMetrics.heightPixels, context);
heightDP = Math.min(Math.max(heightDP, MIN_HEIGHT), MAX_HEIGHT);
int widthDP = PNDeviceUtils.convertPxToDp(displayMetrics.widthPixels, context);
widthDP = Math.min(Math.max(widthDP, MIN_WIDTH), MAX_WIDTH);
mNativeAd.setAdSize(new AdSize(widthDP, heightDP));
mNativeAd.setAdUnitId(unitId);
mNativeAd.setAdListener(mAdListener);
mNativeAd.loadAd(AdMob.getAdRequest(context));
} else {
invokeLoadFail(PNException.ADAPTER_ILLEGAL_ARGUMENTS);
}
}
}
}
示例9: initBannerAds
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
private void initBannerAds() {
// Look up the AdView as a resource and load a request.
NativeExpressAdView adView = (NativeExpressAdView)this.findViewById(R.id.main_adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("BABB35E2F44BD42D7B74D736D34239F2")
.build();
adView.loadAd(adRequest);
//Mechanism to prevent interstitial displaying when banner is active
adView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
isAdActive = false;
}
@Override
public void onAdOpened() {
// Code to be executed when an ad opens an overlay that
// covers the screen.
isAdActive = true;
}
@Override
public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
isAdActive = true;
}
});
}
示例10: initializeAd
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
private void initializeAd() {
NativeExpressAdView avNativeAd = (NativeExpressAdView) findViewById(R.id.av_nativeAd);
avNativeAd.loadAd(new AdRequest.Builder().build());
}
示例11: MyViewHolder
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
public MyViewHolder(View view) {
super(view);
book_name = (TextView) view.findViewById(R.id.mbl_bookname);
book_author = (TextView) view.findViewById(R.id.mbl_bookauthor);
//book_description = (TextView) view.findViewById(R.id.mbl_bookdescription);
book_image = (ImageView) view.findViewById(R.id.mbl_bookimage);
book_exchange_donate = (TextView) view.findViewById(R.id.mbl_exchange_donate);
book_date_posted = (TextView) view.findViewById(R.id.mbl_date_posted);
NativeExpressAdView mAdView = (NativeExpressAdView)view.findViewById(R.id.adViewNative);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("19958886412D28A5FFC7BA20F66C6FF5")
.build();
if (mAdView != null) {
mAdView.loadAd(adRequest);
}
}
示例12: onCreate
import com.google.android.gms.ads.NativeExpressAdView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate() called with: " + "savedInstanceState = [" + this.getDatabasePath("dota2.db") + "]");
setTheme(R.style.Infodota);
super.onCreate(savedInstanceState);
setContentView(R.layout.main_fragment_holder);
TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/future.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf
//mActionMenuView.setPresenter(new ActionMenuPresenter(this));
FacebookSdk.sdkInitialize(getApplicationContext());
// Initialize the Mobile Ads SDK.§
MobileAds.initialize(this, getString(R.string.banner_ad_unit_id));
/* Chartboost.startWithAppId(this, getString(R.string.appIDChartboost), getString(R.string.appSignature));
Chartboost.onCreate(this);*/
AppEventsLogger.activateApp(this);
MenuFragment.updateActivity(this);
Log.d(TAG, "onCreate() called with: " + "savedInstanceState = [" + savedInstanceState + "]");
ActionBar bar = getSupportActionBar();
bar.setDisplayShowTitleEnabled(false);
bar.setDisplayShowHomeEnabled(false);
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
preferences.edit().remove("mainMenuLastSelected").commit();
// BinhTran comment 23/03 for calling redundant
// UpdateUtils.checkNewVersion(this, false);
navSpinner = (Spinner) mToolbar.findViewById(R.id.nav_spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.spinner_item, getResources().getStringArray(R.array.main_menu));
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
navSpinner.setAdapter(adapter);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
int selected = prefs.getInt("mainMenuLastSelected", 0);
navSpinner.setOnItemSelectedListener(this);
navSpinner.setSelection(Math.min(selected, adapter.getCount() - 1));
// navSpinner.setVisibility(View.GONE);
initUI();
initControl();
UpdateUtils.checkNewVersion(this, false);
appContext = this;
AppRater.showRate(appContext);
adView = (NativeExpressAdView) findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder()
.addTestDevice("121EC3F83A2EAFBD46DB00F1773A13A0")
.build();
adView.loadAd(request);
visiableAdview(8);
//не нужен AppRater.onAppLaunched(this);
}