Search in sources :

Example 21 with AdRequest

use of com.google.android.gms.ads.AdRequest in project quickstart-android by firebase.

the class FirstFragment method requestNewInterstitial.

/**
 * Load a new interstitial ad asynchronously.
 */
private void requestNewInterstitial() {
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    // AdMob ad unit IDs are not currently stored inside the google-services.json file.
    // Developers using AdMob can store them as custom values in a string resource file or
    // simply use constants. Note that the ad units used here are configured to return only test
    // ads, and should not be used outside this sample.
    InterstitialAd.load(getContext(), getString(R.string.interstitial_ad_unit_id), adRequest, new InterstitialAdLoadCallback() {

        @Override
        public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
            super.onAdLoaded(interstitialAd);
            mInterstitialAd = interstitialAd;
            // Ad received, ready to display
            if (mLoadInterstitialButton != null) {
                mLoadInterstitialButton.setEnabled(true);
            }
            mInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback() {

                @Override
                public void onAdDismissedFullScreenContent() {
                    super.onAdDismissedFullScreenContent();
                    requestNewInterstitial();
                    beginSecondActivity();
                }
            });
        }

        @Override
        public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
            super.onAdFailedToLoad(loadAdError);
            mInterstitialAd = null;
            Log.w(TAG, "onAdFailedToLoad:" + loadAdError.getMessage());
        }
    });
}
Also used : AdRequest(com.google.android.gms.ads.AdRequest) LoadAdError(com.google.android.gms.ads.LoadAdError) FullScreenContentCallback(com.google.android.gms.ads.FullScreenContentCallback) InterstitialAdLoadCallback(com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback) InterstitialAd(com.google.android.gms.ads.interstitial.InterstitialAd)

Example 22 with AdRequest

use of com.google.android.gms.ads.AdRequest in project BeatBoxer-Free by RxMz.

the class MainActivity method onCreate.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final EditText mEdit = (EditText) findViewById(R.id.editText1);
    final EditText speed = (EditText) findViewById(R.id.speed);
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    mEdit.setText(prefs.getString("autoSave", "kssscssskskscsss"));
    mEdit.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            prefs.edit().putString("autoSave", s.toString()).apply();
        }
    });
    // Getting Ads
    MobileAds.initialize(getApplicationContext(), "ca-app-pub-3150466150343288~2301613454");
    AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    // Get Data Back
    SharedPreferences sometune = getSharedPreferences("autoSave", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sometune.edit();
    editor.putString("autoSave", mEdit.getText().toString()).commit();
    ((Button) findViewById(R.id.b)).setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.b);
            mp.setOnCompletionListener(new OnCompletionListener() {

                public void onCompletion(MediaPlayer mp) {
                    mp.release();
                }
            });
            mp.start();
        }
    });
    ((Button) findViewById(R.id.t)).setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.t);
            mp.setOnCompletionListener(new OnCompletionListener() {

                public void onCompletion(MediaPlayer mp) {
                    mp.release();
                }
            });
            mp.start();
        }
    });
    ((Button) findViewById(R.id.k)).setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.k);
            mp.setOnCompletionListener(new OnCompletionListener() {

                public void onCompletion(MediaPlayer mp) {
                    mp.release();
                }
            });
            mp.start();
        }
    });
    ((Button) findViewById(R.id.start)).setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            MainActivity.this.i = 0;
            final EditText editText = mEdit;
            final EditText editText2 = speed;
            new Thread() {

                public void run() {
                    try {
                        if (editText.getText().toString().toCharArray()[MainActivity.this.i] == 'k' || editText.getText().toString().toCharArray()[MainActivity.this.i] == 'K') {
                            playb();
                        } else if (editText.getText().toString().toCharArray()[MainActivity.this.i] == 's' || editText.getText().toString().toCharArray()[MainActivity.this.i] == 'S') {
                            playt();
                        } else if (editText.getText().toString().toCharArray()[MainActivity.this.i] == 'c' || editText.getText().toString().toCharArray()[MainActivity.this.i] == 'C') {
                            playk();
                        }
                        Thread.sleep(Long.parseLong(editText2.getText().toString()));
                        MainActivity access$0 = MainActivity.this;
                        access$0.i++;
                        if (editText.getText().toString().toCharArray()[MainActivity.this.i] != '\u0000') {
                            run();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                private void playt() {
                    MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.t);
                    mp.setOnCompletionListener(new OnCompletionListener() {

                        public void onCompletion(MediaPlayer mp) {
                            mp.release();
                        }
                    });
                    mp.start();
                }

                private void playk() {
                    MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.k);
                    mp.setOnCompletionListener(new OnCompletionListener() {

                        public void onCompletion(MediaPlayer mp) {
                            mp.release();
                        }
                    });
                    mp.start();
                }

                private void playb() {
                    MediaPlayer mp = MediaPlayer.create(MainActivity.this, R.raw.b);
                    mp.setOnCompletionListener(new OnCompletionListener() {

                        public void onCompletion(MediaPlayer mp) {
                            mp.release();
                        }
                    });
                    mp.start();
                }
            }.start();
        }
    });
    Button reset = (Button) findViewById(R.id.reset);
    reset.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mEdit.setText("kssscssskskscsss");
            AppRater.showRateDialog(MainActivity.this, null);
        }
    });
}
Also used : EditText(android.widget.EditText) SharedPreferences(android.content.SharedPreferences) AdView(com.google.android.gms.ads.AdView) View(android.view.View) ActivityNotFoundException(android.content.ActivityNotFoundException) AdRequest(com.google.android.gms.ads.AdRequest) OnCompletionListener(android.media.MediaPlayer.OnCompletionListener) Button(android.widget.Button) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) OnClickListener(android.view.View.OnClickListener) AdView(com.google.android.gms.ads.AdView) MediaPlayer(android.media.MediaPlayer)

Example 23 with AdRequest

use of com.google.android.gms.ads.AdRequest in project pixel-dungeon-remix by NYRDS.

the class Ads method requestNewInterstitial.

private static void requestNewInterstitial(final InterstitialAd isAd) {
    Boolean loadAlreadyInProgress = mAdLoadInProgress.get(isAd);
    if (loadAlreadyInProgress != null && loadAlreadyInProgress) {
        return;
    }
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(Game.getVar(R.string.testDevice)).build();
    isAd.setAdListener(new AdListener() {

        @Override
        public void onAdClosed() {
            super.onAdClosed();
        }

        @Override
        public void onAdFailedToLoad(int errorCode) {
            super.onAdFailedToLoad(errorCode);
            mAdLoadInProgress.put(isAd, false);
        }

        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mAdLoadInProgress.put(isAd, false);
        }

        @Override
        public void onAdOpened() {
            super.onAdOpened();
        }

        @Override
        public void onAdLeftApplication() {
            super.onAdLeftApplication();
        }
    });
    mAdLoadInProgress.put(isAd, true);
    isAd.loadAd(adRequest);
}
Also used : AdRequest(com.google.android.gms.ads.AdRequest) InterstitialPoint(com.watabou.noosa.InterstitialPoint) AdListener(com.google.android.gms.ads.AdListener)

Example 24 with AdRequest

use of com.google.android.gms.ads.AdRequest 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

AdRequest (com.google.android.gms.ads.AdRequest)24 AdView (com.google.android.gms.ads.AdView)11 SharedPreferences (android.content.SharedPreferences)5 View (android.view.View)4 AdListener (com.google.android.gms.ads.AdListener)4 InterstitialAd (com.google.android.gms.ads.InterstitialAd)4 NavigationView (android.support.design.widget.NavigationView)3 AdSize (com.google.android.gms.ads.AdSize)3 FullScreenContentCallback (com.google.android.gms.ads.FullScreenContentCallback)3 LoadAdError (com.google.android.gms.ads.LoadAdError)3 RequestConfiguration (com.google.android.gms.ads.RequestConfiguration)3 PoolDbHelper (it.angelic.mpw.model.db.PoolDbHelper)3 Toolbar (android.support.v7.widget.Toolbar)2 ViewTreeObserver (android.view.ViewTreeObserver)2 Button (android.widget.Button)2 RadioGroup (android.widget.RadioGroup)2 RelativeLayout (android.widget.RelativeLayout)2 TextView (android.widget.TextView)2 NonNull (androidx.annotation.NonNull)2 AdError (com.google.android.gms.ads.AdError)2