Search in sources :

Example 21 with InterstitialAd

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

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mFragmentContainerView = (View) findViewById(R.id.navigation_drawer);
    mTitle = getTitle();
    applyKitKatTranslucency();
    onNavigationDrawerItemSelected(0);
    initDrawer();
    MobileAds.initialize(this, "ca-app-pub-4369038195513432/2986510514");
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("ca-app-pub-4369038195513432/2986510514");
    mInterstitialAd.loadAd(new AdRequest.Builder().build());
    MyApp myApp = new MyApp();
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
Also used : InterstitialAd(com.google.android.gms.ads.InterstitialAd)

Example 22 with InterstitialAd

use of com.google.android.gms.ads.InterstitialAd in project Android-NotesApp by HelloPraveenIO.

the class EditActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(EditActivity.this);
    premium = preferences.getInt("premium", 0);
    interstitialAd = new InterstitialAd(EditActivity.this);
    interstitialAd.setAdUnitId("ca-app-pub-8429477298745270/2004640333");
    interstitialAd.loadAd(new AdRequest.Builder().build());
    intent = new Intent(EditActivity.this, MainActivity.class);
    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath("fonts/whitney.ttf").setFontAttrId(R.attr.fontPath).build());
    Typeface font2 = Typeface.createFromAsset(getAssets(), "fonts/whitney.ttf");
    SpannableStringBuilder SS = new SpannableStringBuilder("Edit Note");
    SS.setSpan(new CustomTypefaceSpan("", font2), 0, SS.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setTitle(SS);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    String noteText = "", noteTitle = "";
    if (getIntent().getExtras() != null) {
        noteText = getIntent().getExtras().getString("note");
        noteTitle = getIntent().getExtras().getString("title");
    }
    FloatingActionButton fab = findViewById(R.id.edit_fab);
    text = findViewById(R.id.edit_text);
    title = findViewById(R.id.edit_title);
    text.setText(noteText);
    title.setText(noteTitle);
    text.setSelection(noteText != null ? noteText.length() : 0);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(@NonNull View v) {
            String note = text.getText().toString();
            Title = title.getText().toString();
            if (note.length() > 0) {
                Calendar c = Calendar.getInstance();
                SimpleDateFormat df = new SimpleDateFormat("HH:mm dd/MM/yyyy", Locale.ENGLISH);
                String formattedDate = df.format(c.getTime());
                int id = 0;
                if (getIntent().getExtras() != null) {
                    id = getIntent().getExtras().getInt("id");
                }
                DatabaseHandler db = new DatabaseHandler(EditActivity.this);
                db.updateNote(new Note(id, note, formattedDate, imp, Title));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                intent.putExtra("edit", true);
                intent.putExtra("note", true);
                if (interstitialAd.isLoaded() && premium != 1) {
                    interstitialAd.show();
                    interstitialAd.setAdListener(new AdListener() {

                        @Override
                        public void onAdClosed() {
                            startActivity(intent);
                            finish();
                        }
                    });
                } else {
                    startActivity(intent);
                    finish();
                }
            } else
                Snackbar.make(v, "Note is empty!", Snackbar.LENGTH_SHORT).show();
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) Typeface(android.graphics.Typeface) SpannableStringBuilder(android.text.SpannableStringBuilder) Calendar(java.util.Calendar) Intent(android.content.Intent) View(android.view.View) AdListener(com.google.android.gms.ads.AdListener) DatabaseHandler(io.praveen.typenote.SQLite.DatabaseHandler) Note(io.praveen.typenote.SQLite.Note) FloatingActionButton(android.support.design.widget.FloatingActionButton) InterstitialAd(com.google.android.gms.ads.InterstitialAd) SimpleDateFormat(java.text.SimpleDateFormat) SpannableStringBuilder(android.text.SpannableStringBuilder)

Aggregations

InterstitialAd (com.google.android.gms.ads.InterstitialAd)22 Intent (android.content.Intent)12 SpannableStringBuilder (android.text.SpannableStringBuilder)10 View (android.view.View)9 AdListener (com.google.android.gms.ads.AdListener)9 SharedPreferences (android.content.SharedPreferences)8 Typeface (android.graphics.Typeface)8 TaskStackBuilder (android.app.TaskStackBuilder)6 FloatingActionButton (android.support.design.widget.FloatingActionButton)6 DatabaseHandler (io.praveen.typenote.SQLite.DatabaseHandler)6 Note (io.praveen.typenote.SQLite.Note)6 SuppressLint (android.annotation.SuppressLint)4 TargetApi (android.annotation.TargetApi)4 Notification (android.app.Notification)4 NotificationChannel (android.app.NotificationChannel)4 NotificationManager (android.app.NotificationManager)4 PendingIntent (android.app.PendingIntent)4 NotificationCompat (android.support.v4.app.NotificationCompat)4 RecyclerView (android.support.v7.widget.RecyclerView)4 AdRequest (com.google.android.gms.ads.AdRequest)4