当前位置: 首页>>代码示例>>Java>>正文


Java NativeExpressAdView.loadAd方法代码示例

本文整理汇总了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);
}
 
开发者ID:elixsr,项目名称:FwdPortForwardingApp,代码行数:20,代码来源:RuleListAdapter.java

示例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));
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:23,代码来源:AdMobNativeExpressAdapter.java

示例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));
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:22,代码来源:AdMobNativeExpressAdapter.java

示例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;
    }
 
开发者ID:Art2Cat,项目名称:MoonlightNote,代码行数:20,代码来源:SlashFragment.java

示例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);
}
 
开发者ID:albertogiunta,项目名称:justintrain-client-android,代码行数:10,代码来源:Ads.java

示例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());
    }
}
 
开发者ID:tranleduy2000,项目名称:ascii_generate,代码行数:12,代码来源:MainActivity.java

示例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) {

    }
}
 
开发者ID:tranleduy2000,项目名称:ascii_generate,代码行数:15,代码来源:AdBannerActivity.java

示例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);
            }
        }
    }
}
 
开发者ID:pubnative,项目名称:pubnative-android-sdk,代码行数:32,代码来源:AdMobNativeExpressAdapter.java

示例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;
        }

    });
}
 
开发者ID:ruibar,项目名称:android-protwall,代码行数:32,代码来源:ActivityFirst.java

示例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());
}
 
开发者ID:vshkl,项目名称:SaveIg,代码行数:5,代码来源:MainActivity.java

示例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);
        }




}
 
开发者ID:prabhavgupta,项目名称:BookED,代码行数:30,代码来源:AllBooksAdapter.java

示例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);
}
 
开发者ID:mrprona92,项目名称:SecretBrand,代码行数:70,代码来源:ListHolderActivity.java


注:本文中的com.google.android.gms.ads.NativeExpressAdView.loadAd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。