Search in sources :

Example 6 with AdSize

use of com.google.android.gms.ads.AdSize in project LibreraReader by foobnix.

the class ADS method activateAdmobNativeBanner.

public static void activateAdmobNativeBanner(final Activity a, NativeExpressAdView adViewNative) {
    try {
        final FrameLayout frame = (FrameLayout) a.findViewById(R.id.adFrame);
        frame.removeAllViews();
        frame.setVisibility(View.VISIBLE);
        if (adViewNative != null) {
            adViewNative.destroy();
            adViewNative = null;
        }
        adViewNative = new NativeExpressAdView(a);
        adViewNative.setAdUnitId(AppsConfig.ADMOB_NATIVE_BANNER);
        int adSizeHeight = Dips.screenHeightDP() / 9;
        LOG.d("adSizeHeight", adSizeHeight);
        adViewNative.setAdSize(new AdSize(AdSize.FULL_WIDTH, Math.max(82, adSizeHeight)));
        adViewNative.loadAd(ADS.adRequest);
        adViewNative.setAdListener(new AdListener() {

            @Override
            public void onAdFailedToLoad(int arg0) {
                frame.removeAllViews();
            // frame.setVisibility(View.GONE);
            }
        });
        frame.addView(adViewNative);
    } catch (Exception e) {
        LOG.e(e);
    }
}
Also used : NativeExpressAdView(com.google.android.gms.ads.NativeExpressAdView) FrameLayout(android.widget.FrameLayout) AdSize(com.google.android.gms.ads.AdSize) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) AdListener(com.google.android.gms.ads.AdListener)

Example 7 with AdSize

use of com.google.android.gms.ads.AdSize in project superCleanMaster by joyoyao.

the class ResultActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_result);
    Button btngo_to_saving_battery = (Button) findViewById(R.id.goto_saving_battery);
    Button btngoto_memory_clean = (Button) findViewById(R.id.goto_memory_clean);
    Button btngoto_rate_app = (Button) findViewById(R.id.goto_rate_app);
    btngo_to_saving_battery.setOnClickListener(onClickListener);
    btngoto_memory_clean.setOnClickListener(onClickListener);
    btngoto_rate_app.setOnClickListener(onClickListener);
    mAdView = findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    AdSize adSize = new AdSize(300, 250);
    adSize.equals(AdSize.BANNER);
    mAdView.setAdListener(new AdListener() {

        @Override
        public void onAdLoaded() {
            // Code to be executed when an ad finishes loading.
            Log.d(TAG, "onAdLoaded");
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            Log.d(TAG, "onAdFailedToLoad");
        // Code to be executed when an ad request fails.
        }

        @Override
        public void onAdOpened() {
            Log.d(TAG, "onAdOpened");
        // Code to be executed when an ad opens an overlay that
        // covers the screen.
        }

        @Override
        public void onAdLeftApplication() {
            Log.d(TAG, "onAdLeftApplication");
        // Code to be executed when the user has left the app.
        }

        @Override
        public void onAdClosed() {
            Log.d(TAG, "onAdClosed");
        // Code to be executed when when the user is about to return
        // to the app after tapping on an ad.
        }
    });
}
Also used : AdRequest(com.google.android.gms.ads.AdRequest) Button(android.widget.Button) AdSize(com.google.android.gms.ads.AdSize) AdListener(com.google.android.gms.ads.AdListener)

Aggregations

AdSize (com.google.android.gms.ads.AdSize)7 FrameLayout (android.widget.FrameLayout)3 AdListener (com.google.android.gms.ads.AdListener)3 AdRequest (com.google.android.gms.ads.AdRequest)3 AdView (com.google.android.gms.ads.AdView)2 PublisherAdRequest (com.google.android.gms.ads.doubleclick.PublisherAdRequest)2 PublisherAdView (com.google.android.gms.ads.doubleclick.PublisherAdView)2 DisplayMetrics (android.util.DisplayMetrics)1 Button (android.widget.Button)1 RelativeLayout (android.widget.RelativeLayout)1 NativeExpressAdView (com.google.android.gms.ads.NativeExpressAdView)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1