示例#1
0
  private void showInterstitial() {
    if (interstitial == null) {
      interstitial = new InterstitialAd(this);
      interstitial.setAdUnitId(getResources().getString(R.string.interstitial_unit_id));
      interstitial.setAdListener(
          new AdListener() {
            @Override
            public void onAdLoaded() {
              if (interstitial.isLoaded()) {
                interstitial.show();
                timeForRun = Calendar.getInstance().getTime().getTime();
                numberOfSelectItem = 1;
              }
            }

            @Override
            public void onAdClosed() {}

            @Override
            public void onAdFailedToLoad(int errorCode) {}
          });
    }

    AdRequest adRequest_interstitial = new AdRequest.Builder().build();

    interstitial.loadAd(adRequest_interstitial);
  }
示例#2
0
  void initAd() {
    // Create an ad.
    interstitialAd = new InterstitialAd(this);
    //		interstitialAd.setAdUnitId(AD_UNIT_ID_INTER);

    // Set the AdListener.
    interstitialAd.setAdListener(
        new AdListener() {
          @Override
          public void onAdLoaded() {
            Log.d(LOG_TAG, "onAdLoaded");
            Toast.makeText(MainActivity.this, "onAdLoaded", Toast.LENGTH_SHORT).show();

            // Change the button text and enable the button.
            interstitialAd.show();
          }

          @Override
          public void onAdFailedToLoad(int errorCode) {
            String message = String.format("onAdFailedToLoad (%s)", getErrorReason(errorCode));
            Log.d(LOG_TAG, message);
            Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();

            // Change the button text and disable the button.
          }
        });
  }
示例#3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.learndigits);
    try {

      toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);

      SharedPreferences pref = getSharedPreferences("ASL", Context.MODE_PRIVATE);
      CommonThings.PAID_APP = pref.getString("PAID", "temp");
      if (CommonThings.PAID_APP.equalsIgnoreCase("temp")) {

        AdView adView = (AdView) this.findViewById(R.id.adView);
        AdRequest adRequest =
            new AdRequest.Builder().addTestDevice("A38A51D43110AAD81A8E3AE3AC468C32").build();
        adView.loadAd(adRequest);

        // Interstitials ad

        interstitialAd = new InterstitialAd(this);
        interstitialAd.setAdUnitId(getResources().getString(R.string.interstitialid));
        interstitialAd.loadAd(adRequest);
        interstitialAd.setAdListener(
            new AdListener() {
              @Override
              public void onAdLoaded() {
                // TODO Auto-generated method stub
                DisplayAd();
              }
            });
      }

      //

      btn_nex = (ImageButton) findViewById(R.id.btnForward);
      btn_back = (ImageButton) findViewById(R.id.btnBackward);
      btn_last = (ImageButton) findViewById(R.id.btnNext);
      btn_first = (ImageButton) findViewById(R.id.btnPrevious);
      imageView1 = (ImageView) findViewById(R.id.imageView1);
      tv_hotvines = (TextView) findViewById(R.id.tv_hotvines);
      animationFadeIn = AnimationUtils.loadAnimation(this, R.anim.right_out);

      mp = MediaPlayer.create(this, sounds[curr]);
      mp.start();

      btn_nex.setOnClickListener(this);
      btn_back.setOnClickListener(this);
      btn_first.setOnClickListener(this);
      btn_last.setOnClickListener(this);
      tv_hotvines.setOnClickListener(this);
    } catch (Exception ex) {
      DebugLog.console(ex, "Learn_Digits onCreate Exception");
    }
  }
    /**
     * Initialize the interstitial ads
     *
     * @param c
     */
    public void initAds(Context c) {
      interstitialAd = new InterstitialAd(c);
      interstitialAd.setAdUnitId("a15391920065568");
      interstitialAd.setAdListener(adListener);

      AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
      adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
      // adRequestBuilder.addTestDevice("D9B017A3983BD8CB8B38C927F7C5E330");
      adRequest = adRequestBuilder.build();
      interstitialAd.loadAd(adRequest);
    }
  public void onCreate(Bundle var1) {
    super.onCreate(var1);
    this.getWindow().addFlags(128);

    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
    cfg.useGL20 = false;
    cfg.useAccelerometer = true;
    cfg.useCompass = false;

    this.requestWindowFeature(1);
    this.getWindow().setFlags(1024, 1024);
    this.getWindow().clearFlags(2048);

    layout = new RelativeLayout(this);
    layout.setLayoutParams(new LayoutParams(-1, -1));

    adView = this.createAdView();
    // layout.addView(adView);
    layout.addView(this.createGameView(cfg));

    this.setContentView(layout);
    this.startAdvertising(adView);

    this.interstitialAd = new InterstitialAd(this);
    this.interstitialAd.setAdUnitId(AD_UNIT_ID_INTERSTITIAL);
    interstitialAd.setAdListener(
        new AdListener() {
          @Override
          public void onAdLoaded() {
            if (DEBUG) {
              Toast.makeText(
                      getApplicationContext(), "Finished Loading Interstitial", Toast.LENGTH_SHORT)
                  .show();
            }
          }

          @Override
          public void onAdClosed() {
            if (DEBUG) {
              Toast.makeText(getApplicationContext(), "Closed Interstitial", Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });

    if (this.gameHelper == null) {
      this.gameHelper = new GameHelper(this, 1);
      this.gameHelper.enableDebugLog(true);
    }

    this.gameHelper.setup(this);
  }
  private void initInterstitialAd() {
    mInterstitialAd = new InterstitialAd(this);

    /*
      Replace AD_UNIT_ID with your unique Ad Unit ID.
      Please, read official documentation how to obtain one: https://apps.admob.com
    */
    mInterstitialAd.setAdUnitId(AD_UNIT_ID);

    mAdRequest = new AdRequest.Builder().build();

    mInterstitialAd.setAdListener(mInterstitialAdListener);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_main, container, false);

    mInterstitialAd = new InterstitialAd(getContext());
    mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
    mInterstitialAd.setAdListener(
        new AdListener() {
          @Override
          public void onAdClosed() {
            super.onAdClosed();
            mInterstitialAd.loadAd(getTestAdRequest());
            launchJokeActivity(mJoke);
          }
        });
    mInterstitialAd.loadAd(getTestAdRequest());

    AdView mAdView = (AdView) root.findViewById(R.id.adView);
    mAdView.loadAd(getTestAdRequest());

    final ProgressBar progressBar = (ProgressBar) root.findViewById(R.id.progress_bar);

    Button tellJokeButton = (Button) root.findViewById(R.id.tell_joke_button);
    tellJokeButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            progressBar.setVisibility(View.VISIBLE);
            new FetchJokeAsyncTask()
                .execute(
                    new FetchJokeAsyncTask.FetchJokeTaskCallback() {
                      @Override
                      public void handleJoke(String joke) {
                        mJoke = joke;
                        progressBar.setVisibility(View.GONE);
                        if (mInterstitialAd.isLoaded()) {
                          mInterstitialAd.show();
                        } else {
                          launchJokeActivity(joke);
                        }
                      }
                    });
          }
        });
    return root;
  }
示例#8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test_ad_mob);

    // Create the next level button, which tries to show an interstitial when clicked.
    mNextLevelButton = ((Button) findViewById(R.id.next_level_button));
    mNextLevelButton.setEnabled(false);
    mNextLevelButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            showInterstitial();
          }
        });

    // Create the text view to show the level number.
    mLevelTextView = (TextView) findViewById(R.id.level);
    mLevel = START_LEVEL;

    // Create the InterstitialAd and set the adUnitId (defined in values/strings.xml).
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId(getString(R.string.interstitial_ad_unit_id));
    mInterstitialAd.setAdListener(
        new AdListener() {
          @Override
          public void onAdLoaded() {
            mNextLevelButton.setEnabled(true);
          }

          @Override
          public void onAdFailedToLoad(int errorCode) {
            mNextLevelButton.setEnabled(true);
          }

          @Override
          public void onAdClosed() {
            // Proceed to the next level.
            goToNextLevel();
          }
        });
    loadInterstitial();

    // Toasts the test ad message on the screen. Remove this after defining your own ad unit ID.
    Toast.makeText(this, TOAST_TEXT, Toast.LENGTH_LONG).show();
  }
示例#9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // https://developers.google.com/admob/android/interstitial?hl=en
    mInterstitialAd = new InterstitialAd(this);
    // hard-coded "test" interstitial add id
    mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
    mInterstitialAd.setAdListener(
        new AdListener() {
          @Override
          public void onAdClosed() {
            requestNewInterstitial();
          }
        });

    requestNewInterstitial();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    MobileAds.initialize(getApplicationContext(), "ca-app-pub-7818455682102414~3747009689");
    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("ca-app-pub-7818455682102414/8273221287");

    mInterstitialAd.setAdListener(
        new AdListener() {
          @Override
          public void onAdClosed() {
            Log.d("YellowAndDangerous", "onAdClosed");
            requestNewInterstitial();
            showingAd = false;
          }
        });

    requestNewInterstitial();
  }
  @Override
  protected void onPostExecute(String result) {
    super.onPostExecute(result);
    mResult = result;
    // Setting the interstitial ad
    interstitialAd = new InterstitialAd(context);
    interstitialAd.setAdUnitId(context.getString(R.string.interstitial_ad_unit_id));
    interstitialAd.setAdListener(
        new AdListener() {
          @Override
          public void onAdLoaded() {
            super.onAdLoaded();
            if (progressBar != null) {
              progressBar.setVisibility(View.GONE);
            }
            interstitialAd.show();
          }

          @Override
          public void onAdFailedToLoad(int errorCode) {
            super.onAdFailedToLoad(errorCode);
            if (progressBar != null) {
              progressBar.setVisibility(View.GONE);
            }
            startJokeActivity();
          }

          @Override
          public void onAdClosed() {
            startJokeActivity();
          }
        });
    AdRequest ar = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();

    interstitialAd.loadAd(ar);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fullimageslider);
    db = new DatabaseHandler(this);
    dbManager = DatabaseManager.INSTANCE;
    dbManager.init(getApplicationContext());
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    options =
        new DisplayImageOptions.Builder()
            .showImageForEmptyUri(R.drawable.ic_launcher)
            .showImageOnFail(R.drawable.ic_launcher)
            .resetViewBeforeLoading(true)
            .cacheOnDisc(true)
            .imageScaleType(ImageScaleType.EXACTLY)
            .bitmapConfig(Bitmap.Config.RGB_565)
            .considerExifParams(true)
            .displayer(new FadeInBitmapDisplayer(300))
            .build();

    setTitle(Constant.CATEGORY_TITLE);
    // Look up the AdView as a resource and load a request.
    mAdView = (AdView) findViewById(R.id.adView);
    mAdView.loadAd(new AdRequest.Builder().build());

    Intent i = getIntent();
    position = i.getIntExtra("POSITION_ID", 0);
    mAllImages = i.getStringArrayExtra("IMAGE_ARRAY");
    mAllImageCatName = i.getStringArrayExtra("IMAGE_CATNAME");

    TOTAL_IMAGE = mAllImages.length - 1;
    viewpager = (ViewPager) findViewById(R.id.image_slider);
    handler = new Handler();

    PinchZoomPageAdapter adapter = new PinchZoomPageAdapter(this, mAllImages, mAllImageCatName);
    viewpager.setAdapter(adapter);
    viewpager.setCurrentItem(position);

    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    lastUpdate = System.currentTimeMillis();
    mCountPage = 0;
    mInterstitial = new InterstitialAd(this);
    mInterstitial.setAdUnitId(getResources().getString(R.string.admob_publisher_id));
    request = new AdRequest.Builder().addTestDevice("7F0E780CC56F3BA7C1CA7488A61F46BE").build();

    mInterstitial.loadAd(request);
    mInterstitial.setAdListener(
        new AdListener() {
          @Override
          public void onAdClosed() {
            mInterstitial.loadAd(request);
          }
        });
    viewpager.setOnPageChangeListener(
        new OnPageChangeListener() {

          @Override
          public void onPageSelected(int position) {
            // TODO Auto-generated method stub
            mCountPage++;
            Log.d("haipn", "page count:" + mCountPage);
            if (mCountPage >= 20) {

              if (mInterstitial.isLoaded()) {
                mInterstitial.show();
                mCountPage = 0;
              }
            }
            position = viewpager.getCurrentItem();
            Image_Url = mAllImages[position];

            List<Pojo> pojolist = db.getFavRow(Image_Url);
            if (pojolist.size() == 0) {
              menu.getItem(3).setIcon(getResources().getDrawable(R.drawable.fav));
            } else {
              if (pojolist.get(0).getImageurl().equals(Image_Url)) {
                menu.getItem(3).setIcon(getResources().getDrawable(R.drawable.fav_hover));
              }
            }
          }

          @Override
          public void onPageScrolled(int arg0, float arg1, int position) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onPageScrollStateChanged(int position) {
            // TODO Auto-generated method stub

          }
        });
  }
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    questionAnswers = getArguments().getParcelableArrayList(QUESTIONS_ANSWERS);

    View view = inflater.inflate(R.layout.fragment_completed_test, container, false);
    ButterKnife.inject(this, view);

    Typeface type = Typeface.createFromAsset(getActivity().getAssets(), "fonts/8408.ttf");

    buttonNeutral.setOnClickListener(onClickListener);
    buttonCalm.setOnClickListener(onClickListener);
    buttonAgressive.setOnClickListener(onClickListener);

    counterAnswer = 0;
    for (int i = 0; i < questionAnswers.size(); i++)
      if (questionAnswers.get(i).getAnswer()) counterAnswer += 1;

    if (counterAnswer < 13) {
      reCalm.setVisibility(View.VISIBLE);
      reNeutral.setVisibility(View.GONE);
      reAgressive.setVisibility(View.GONE);

      buttonCalm.setText(getActivity().getResources().getString(R.string.repeat_test));
      buttonCalm.setTypeface(type);
    } else if (counterAnswer < 27) {
      reCalm.setVisibility(View.GONE);
      reNeutral.setVisibility(View.VISIBLE);
      reAgressive.setVisibility(View.GONE);

      buttonNeutral.setText(getActivity().getResources().getString(R.string.repeat_test));
      buttonNeutral.setTypeface(type);
    } else {
      reCalm.setVisibility(View.GONE);
      reNeutral.setVisibility(View.GONE);
      reAgressive.setVisibility(View.VISIBLE);

      buttonAgressive.setText(getActivity().getResources().getString(R.string.repeat_test));
      buttonAgressive.setTypeface(type);
    }

    statisticAnger = new ArrayList<Integer>();
    for (int i = 0; i < 8; i++) statisticAnger.add(0);
    sizeArrayQuestions = questionAnswers.size();

    int phisycalAgressive = 0;
    int indirectAgressive = 0;
    int irritability = 0;
    int negativism = 0;
    int resentment = 0;
    int suspicion = 0;
    int verbalAggression = 0;
    int guilt = 0;

    for (int i = 0; i < questionAnswers.size(); i++) {
      switch (i % 8) {
        case 0:
          if (questionAnswers.get(i).getAnswer()) phisycalAgressive++;
          break;
        case 1:
          if (questionAnswers.get(i).getAnswer()) indirectAgressive++;
          break;
        case 2:
          if (questionAnswers.get(i).getAnswer()) irritability++;
          break;
        case 3:
          if (questionAnswers.get(i).getAnswer()) negativism++;
          break;
        case 4:
          if (questionAnswers.get(i).getAnswer()) resentment++;
          break;
        case 5:
          if (questionAnswers.get(i).getAnswer()) suspicion++;
          break;
        case 6:
          if (questionAnswers.get(i).getAnswer()) verbalAggression++;
          break;
        case 7:
          if (questionAnswers.get(i).getAnswer()) guilt++;
          break;
      }
    }

    int[] resultNumbers = {
      phisycalAgressive,
      indirectAgressive,
      irritability,
      negativism,
      resentment,
      suspicion,
      verbalAggression,
      guilt
    };

    ResultAdapter adapter = new ResultAdapter(getActivity(), resultNumbers);
    resultListView.setDivider(null);
    resultListView.setAdapter(adapter);

    RateThisApp.Config config = new RateThisApp.Config(1, 5);
    // Custom title ,message and buttons names
    config.setTitle(R.string.rate_title);
    config.setMessage(R.string.rate_message);
    config.setYesButtonText(R.string.rate_us);
    config.setNoButtonText(R.string.rate_remind);
    config.setCancelButtonText(R.string.rate_no);
    RateThisApp.init(config);

    mInterstitialAd = new InterstitialAd(getActivity());
    mInterstitialAd.setAdUnitId("ca-app-pub-5534695259936833/8187237908");

    mInterstitialAd.setAdListener(
        new AdListener() {
          @Override
          public void onAdClosed() {
            requestNewInterstitial();
            beginPlayingGame();
          }
        });

    requestNewInterstitial();

    return view;
  }