Exemplo n.º 1
1
  public static void manageAds(Activity activity) {
    final PackageManager pm = activity.getPackageManager();
    // get a list of installed apps.
    List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

    boolean yboTvProFound = false;

    for (ApplicationInfo info : packages) {
      if (PACKAGE_PRO.equals(info.packageName)) {
        yboTvProFound = true;
        break;
      }
    }

    // Look up the AdView as a resource and load a request.
    AdView adView = (AdView) activity.findViewById(R.id.adView);
    if (yboTvProFound) {
      View layout = activity.findViewById(R.id.ad_container);
      FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) layout.getLayoutParams();
      layoutParams.bottomMargin = 0;
      layout.setLayoutParams(layoutParams);
      adView.setVisibility(View.GONE);
    } else {
      adView.loadAd(new AdRequest.Builder().build());
    }
  }
Exemplo n.º 2
0
 // ADS
 private void startAds() {
   AdView adView = (AdView) findViewById(R.id.adView);
   AdRequest adRequest =
       new AdRequest.Builder().addTestDevice("FA62693DA83DCD07CE56E8226B7FAF61").build();
   adView.loadAd(adRequest);
   adView.setVisibility(View.VISIBLE);
 }
 @Override
 public void setUp(View view) {
   AdView mAdView = (AdView) view.findViewById(R.id.adView);
   AdRequest adRequest =
       new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
   mAdView.loadAd(adRequest);
 }
Exemplo n.º 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mTracker = AnalyticsTrackers.getInstance().get(AnalyticsTrackers.Target.APP);
    // Load an ad into the AdMob banner view.
    AdView adView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest =
        new AdRequest.Builder().setRequestAgent("android_studio:ad_template").build();
    adView.loadAd(adRequest);

    // 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();
    mText = (EditText) findViewById(R.id.partno);
    mStart = findViewById(R.id.imageView1);

    mText.setOnEditorActionListener(ActionListener.newInstance(this));
    mStart.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (!TextUtils.isEmpty(mText.getText())) {
              String s = mText.getText().toString();
              Intent i = new Intent(getBaseContext(), Game.class);
              i.putExtra("number", s);
              startActivity(i);
              finish();
            } else {
              Toast.makeText(MainActivity.this, TOAST_TEXT, Toast.LENGTH_LONG).show();
            }
          }
        });
  }
Exemplo n.º 5
0
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    adView = new AdView(this);
    adView.setAdUnitId("ca-app-pub-9480879598480702/4025467071");
    adView.setAdSize(AdSize.SMART_BANNER);

    RelativeLayout rl = new RelativeLayout(this);
    RelativeLayout.LayoutParams lay =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    lay.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    com.google.android.gms.ads.AdRequest adRequest =
        new com.google.android.gms.ads.AdRequest.Builder()
            .addTestDevice("13F77AAABEE7FB57CF4FA6BD90138B61")
            .build();
    panel = new MainGamePanel(this, adView);
    rl.addView(panel);
    rl.addView(adView, lay);

    // Carregar o adView com a solicitação de anúncio.
    adView.loadAd(adRequest);
    setContentView(rl);

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

    spinner = (ProgressBar) root.findViewById(R.id.spinner);
    spinner.setVisibility(View.GONE);

    Button btnTellJoke = (Button) root.findViewById(R.id.tell_joke_btn);
    btnTellJoke.setOnClickListener(this);

    mPublisherInterstitialAd = new PublisherInterstitialAd(getActivity());
    mPublisherInterstitialAd.setAdUnitId(getString(R.string.intertistial_ad_unit_id));

    mPublisherInterstitialAd.setAdListener(
        new AdListener() {
          @Override
          public void onAdClosed() {
            requestNewInterstitial();
            displayJokeIntent(joke);
          }
        });

    requestNewInterstitial();

    AdView mAdView = (AdView) root.findViewById(R.id.adView);
    AdRequest adRequest =
        new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
    mAdView.loadAd(adRequest);
    return root;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    ((ReadingChallengeApplication) getApplication()).inject(this);

    gridView = (GridView) findViewById(R.id.gridview);

    ((ReadingChallengeApplication) this.getApplication())
        .setDisplay(readSharedPreferences(getString(R.string.display)));

    // listen refresh event
    layout = (PullRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    layout.setOnRefreshListener(
        new PullRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            getCategories();
          }
        });
    getCategories();

    // admobs
    AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);

    // analytics
    ReadingChallengeApplication application = (ReadingChallengeApplication) getApplication();
    Tracker mTracker = application.getDefaultTracker();
    mTracker.setScreenName("HomeActivity");
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());
  }
Exemplo n.º 8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_history);
    ButterKnife.inject(this);

    realm = Realm.getInstance(this);

    getSupportActionBar().setTitle("Riwayat Wisata");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    locationModels = new ArrayList<>();
    adapterRoute = new ListRouteAdapter(this, locationModels);

    updateView();

    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapterRoute);
    recyclerView.addOnItemTouchListener(
        new RecyclerItemClickListener(this, this) {
          @Override
          public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {}
        });
    readDataFromDb();

    AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
  }
  private void _initAdView() {
    try {
      mViewAdv = findViewById(R.id.mViewAdv);
      // get value form task manager
      Container container = LazzyBeeSingleton.getContainerHolder().getContainer();
      String admob_pub_id = null;
      String adv_id = null;
      if (container == null) {
      } else {
        admob_pub_id = container.getString(LazzyBeeShare.ADMOB_PUB_ID);
        adv_id = container.getString(LazzyBeeShare.ADV_DETAILS_ID);
        Log.i(TAG, "admob -admob_pub_id:" + admob_pub_id);
        Log.i(TAG, "admob -adv_id:" + adv_id);
      }
      if (admob_pub_id != null) {
        if (adv_id == null || adv_id.equals(LazzyBeeShare.EMPTY)) {
          mViewAdv.setVisibility(View.GONE);
        } else if (adv_id != null
            || adv_id.length() > 1
            || !adv_id.equals(LazzyBeeShare.EMPTY)
            || !adv_id.isEmpty()) {
          String advId = admob_pub_id + "/" + adv_id;
          Log.i(TAG, "admob -AdUnitId:" + advId);
          AdView mAdView = new AdView(this);

          mAdView.setAdSize(AdSize.BANNER);
          mAdView.setAdUnitId(advId);

          AdRequest adRequest =
              new AdRequest.Builder()
                  .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                  .addTestDevice(getResources().getStringArray(R.array.devices)[0])
                  .addTestDevice(getResources().getStringArray(R.array.devices)[1])
                  .addTestDevice(getResources().getStringArray(R.array.devices)[2])
                  .addTestDevice(getResources().getStringArray(R.array.devices)[3])
                  .build();

          mAdView.loadAd(adRequest);

          RelativeLayout relativeLayout = ((RelativeLayout) findViewById(R.id.adView));
          RelativeLayout.LayoutParams adViewCenter =
              new RelativeLayout.LayoutParams(
                  ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
          adViewCenter.addRule(RelativeLayout.CENTER_IN_PARENT);
          relativeLayout.addView(mAdView, adViewCenter);

          mViewAdv.setVisibility(View.VISIBLE);
        } else {
          mViewAdv.setVisibility(View.GONE);
        }
      } else {
        mViewAdv.setVisibility(View.GONE);
      }
    } catch (Exception e) {
      LazzyBeeShare.showErrorOccurred(context, "_initAdView", e);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    final ViewGroup mainView = (ViewGroup) findViewById(R.id.container);
    ArrayList<View> buttons = getButtons(mainView);
    for (int i = 0; i < buttons.size(); i++) {
      Button button = (Button) buttons.get(i);
      String title = "Click me";
      switch (i) {
        case 0:
          title = "Top, small, custom color";
          break;
        case 1:
          title = "Top, large, custom font/bg, squared";
          break;
        case 2:
          title = "Bottom, small, square";
          break;
        case 3:
          title = "Bottom, large";
          break;

        case 4:
          title = "Text notification";
          break;

        case 5:
          title = "Facebook, different text colors";
          break;

        case 6:
          title = "Incoming call, persistent, tap to dismiss";
          break;
        case 7:
          title = "Music now playing";
          break;
        case 8:
          title = "Ordinary toast with icon";
          break;

        case 9:
          title = "Attention toast with timeout and custom animations";
          break;

        case 10:
          title = "Google Play Games log-in";
          break;
      }
      button.setText(title);
      button.setTag(i);
      button.setOnClickListener(this);
    }
  }
Exemplo n.º 11
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");
    }
  }
Exemplo n.º 12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mSectionsPagerAdapter = new CalculatorPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.addOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          @Override
          public void onPageScrolled(
              int position, float positionOffset, int positionOffsetPixels) {}

          /**
           * Refreshes the listView in the history fragment whenever the user moves to it.
           *
           * @param position page index moving to
           */
          @Override
          public void onPageSelected(int position) {
            CalculatorPagerAdapter fragmentPagerAdapter =
                (CalculatorPagerAdapter) mViewPager.getAdapter();
            if (position == HISTORY_PAGE_INDEX)
              ((HistoryFragment) fragmentPagerAdapter.getRegisteredFragment(position))
                  .refreshHistory();
          }

          @Override
          public void onPageScrollStateChanged(int state) {}
        });

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    // Show welcome demo if this is the first launch
    mSPref = PreferenceManager.getDefaultSharedPreferences(this);
    if (mSPref.getBoolean(getString(R.string.pref_is_first_launch_key), true)) showWelcomeDemo();

    if (!isPro()) {
      AdView adView = (AdView) findViewById(R.id.main_ad_view);
      AdRequest adRequest = new AdRequest.Builder().build();
      adView.loadAd(adRequest);

      // Move up viewPager to allow room for adView
      ((RelativeLayout.LayoutParams) mViewPager.getLayoutParams())
          .addRule(RelativeLayout.ABOVE, R.id.main_ad_view);
    }
  }
Exemplo n.º 13
0
  /** Called when an ad failed to load. */
  @Override
  public void onAdFailedToLoad(int error) {
    Log.d(TAG, "onBannerFailedToLoad");

    Log.d(TAG, "Hiding banner with id " + id);
    AdView view = AdMobExtension.getBannerViewForUnitId(id);
    view.setVisibility(View.INVISIBLE);
    AdMobExtension.getLayout().removeView(view);
    AdMobExtension.getLayout().bringToFront();

    AdMobExtension.callHaxe("onBannerFailedToLoad", new Object[] {id});
  }
Exemplo n.º 14
0
  @Override
  public void onCreate(Bundle savedInstanceBundle) {
    super.onCreate(savedInstanceBundle);
    setContentView(R.layout.activity_funny_cheezy);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle("Funny, Cheezy Pickup Lines");

    AdView mAdView = (AdView) findViewById(R.id.funnyAndCheezyAdView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
  }
  private void addAd() {
    // Create the adView
    AdView adView = new AdView(this);
    adView.setAdSize(AdSize.SMART_BANNER);
    adView.setAdUnitId(getString(R.string.banner_ad_unit_id));

    ((ViewGroup) findViewById(android.R.id.list).getParent().getParent().getParent())
        .addView(adView, 0);

    // Initiate a generic request to load it with an ad
    adView.loadAd(
        new AdRequest.Builder().addTestDevice("5B5C0102B231DC20553952DAC00561A6").build());
  }
Exemplo n.º 16
0
  private void initAdView() {
    LinearLayout layout = (LinearLayout) findViewById(R.id.layout);
    mAdview = new AdView(this);
    mAdview.setAdUnitId(ADID);
    mAdview.setAdSize(AdSize.BANNER);

    layout.addView(mAdview);

    // Initiate a generic request.
    AdRequest adRequest = new AdRequest.Builder().build();

    // Load the adView with the ad request.
    mAdview.loadAd(adRequest);
  }
Exemplo n.º 17
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_main, container, false);
    Toast.makeText(getContext(), "free version", Toast.LENGTH_LONG).show();

    AdView mAdView = (AdView) root.findViewById(R.id.adView);
    // Create an ad request. Check logcat output for the hashed device ID to
    // get test ads on a physical device. e.g.
    // "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to get test ads on this device."
    AdRequest adRequest =
        new AdRequest.Builder().addTestDevice("03771C4932F89866CF4E2662021BF5B4").build();
    mAdView.loadAd(adRequest);
    return root;
  }
Exemplo n.º 18
0
  /** @description function to display the previous exam score of the user. */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.raulgupta.exam.R.layout.activity_view_test_score);
    score = (TextView) findViewById(com.raulgupta.exam.R.id.textView2);
    StringBuffer sb = new StringBuffer("\n");
    if (getIntent().getExtras().containsKey("score")
        && getIntent().getExtras().containsKey("test_Name")) {
      String[] allScore = getIntent().getExtras().getStringArray("score");
      String[] allTest = getIntent().getExtras().getStringArray("test_Name");

      // score.setText("Score : "+getIntent().getExtras().getString("score") + " %");
      sb.append("Score\n");
      for (int i = 0; i < 3; i++) {
        if (allScore[i] != null && allTest[i] != null) {
          sb.append(allTest[i].toUpperCase() + " : ");
          sb.append(allScore[i]);
        }
        sb.append("\n");
      }
      score.setText(sb);
      score.setTextColor(Color.BLACK);
    }
    if (getIntent().getExtras().containsKey("score")
        && getIntent().getExtras().containsKey("user_Name")) {
      String[] allScore = getIntent().getExtras().getStringArray("score");
      String[] allTest = getIntent().getExtras().getStringArray("user_Name");
      String[] allCountry = getIntent().getExtras().getStringArray("country");
      // score.setText("Score : "+getIntent().getExtras().getString("score") + " %");
      sb.append("LeaderBoard\n");
      for (int i = 0; i < 5; i++) {
        if (allScore[i] != null && allTest[i] != null) {
          sb.append(allTest[i].toUpperCase() + " : ");
          sb.append(allScore[i] + " : ");
          sb.append(allCountry[i]);
        }
        sb.append("\n");
      }
      score.setTextSize(20);
      score.setText(sb);
      score.setTextColor(Color.BLACK);
    }

    MobileAds.initialize(getApplicationContext(), "ca-app-pub-5127965163149320~6624066694");
    AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
  } // end of onCreate()
Exemplo n.º 19
0
 @Override
 protected void onDestroy() {
   if (mAdView != null) {
     mAdView.destroy();
   }
   super.onDestroy();
 }
Exemplo n.º 20
0
 @Override
 public void onResume() {
   super.onResume();
   adView.resume();
   uiHelper.onResume();
   imageFetcher.setExitTasksEarly(false);
 }
Exemplo n.º 21
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   uiHelper.onDestroy();
   adView.destroy();
   imageFetcher.closeCache();
 }
Exemplo n.º 22
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getSlidingMenu().setMode(SlidingMenu.LEFT);

    // getSlidingMenu().setSlidingEnabled(false);
    // getSlidingMenu().setSecondaryMenu(R.layout.layout_menu_left);

    me = MainActivity.this;

    initUI();
    Bundle extras = new Bundle();
    extras.putString("appname", "lich_van_lien_2016");
    extras.putString("appcat", "productivity");
    extras.putString("jb", "" + RootSupport.isDeviceRooted());

    AdMobExtras adExtra = new AdMobExtras(extras);

    mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest =
        new AdRequest.Builder()
            .addNetworkExtras(adExtra)
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice("EDA8BB96AFAC4D787093E74267389265")
            .addTestDevice("3D7268CC8E6A7666958991A316D08A88")
            .addTestDevice("7AFC6206AD04A3073968C664E902FF5D")
            .addTestDevice("780C9B0B7E4E49713CFE54EEF2C2F0E7")
            .addTestDevice("48A720DA7ABCF53ECC3A00DEB6983B97")
            .build();
    mAdView.loadAd(adRequest);
  }
Exemplo n.º 23
0
  private void addAds() {
    adView = (AdView) findViewById(R.id.adView);
    adView.setAdListener(
        new AdListener() {

          @Override
          public void onAdLoaded() {
            adView.getLayoutParams().height = LayoutParams.WRAP_CONTENT;
          }
        });

    AdRequest adRequest =
        new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();

    adView.loadAd(adRequest);
  }
Exemplo n.º 24
0
 @Override
 public void onResume() {
   super.onResume();
   if (adView != null) {
     adView.resume();
   }
 }
Exemplo n.º 25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);

    // Registers the declared buttons with their id's, which were set when the layout was created.
    clearButton = (Button) findViewById(R.id.clearButton);
    oButton = (Button) findViewById(R.id.oButton);
    xButton = (Button) findViewById(R.id.xButton);
    topLeftButton = (Button) findViewById(R.id.topLeftButton);
    topMiddleButton = (Button) findViewById(R.id.topMiddleButton);
    topRightButton = (Button) findViewById(R.id.topRightButton);
    middleLeftButton = (Button) findViewById(R.id.middleLeftButton);
    middleButton = (Button) findViewById(R.id.middleButton);
    middleRightButton = (Button) findViewById(R.id.middleRightButton);
    bottomLeftButton = (Button) findViewById(R.id.bottomLeftButton);
    bottomMiddleButton = (Button) findViewById(R.id.bottomMiddleButton);
    bottomRightButton = (Button) findViewById(R.id.bottomRightButton);

    // calls the setupListeners method
    setupListeners();

    // Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in
    // values/strings.xml.
    mAdView = (AdView) findViewById(R.id.ad_view);

    // Create an ad request. Check your logcat output for the hashed device ID to
    // get test ads on a physical device. e.g.
    // "Use AdRequest.Builder.addTestDevice("ABCDEF012345") to get test ads on this device."
    AdRequest adRequest =
        new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();

    // Start loading the ad in the background.
    mAdView.loadAd(adRequest);
  }
Exemplo n.º 26
0
 @Override
 public void onPause() {
   if (adView != null) {
     adView.pause();
   }
   super.onPause();
 }
Exemplo n.º 27
0
 /** Called before the activity is destroyed */
 @Override
 public void onDestroy() {
   if (mAdView != null) {
     mAdView.destroy();
   }
   super.onDestroy();
 }
  @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;
  }
Exemplo n.º 29
0
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_fragment_kqnhnt);
    Bundle extras = new Bundle();
    extras.putString("appname", "lich_van_lien_2016");
    extras.putString("appcat", "productivity");
    extras.putString("jb", "" + RootSupport.isDeviceRooted());

    AdMobExtras adExtra = new AdMobExtras(extras);

    mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest =
        new AdRequest.Builder()
            .addNetworkExtras(adExtra)
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice("EDA8BB96AFAC4D787093E74267389265")
            .addTestDevice("3D7268CC8E6A7666958991A316D08A88")
            .addTestDevice("7AFC6206AD04A3073968C664E902FF5D")
            .addTestDevice("780C9B0B7E4E49713CFE54EEF2C2F0E7")
            .addTestDevice("48A720DA7ABCF53ECC3A00DEB6983B97")
            .build();
    mAdView.loadAd(adRequest);
    iv_back = (ImageView) findViewById(R.id.iv_back);
    iv_share = (ImageView) findViewById(R.id.iv_share);
    iv_back.setOnClickListener(this);
    iv_share.setOnClickListener(this);
    wv_ketqua_nhnt = (WebView) findViewById(R.id.wv_ketqua_nhnt);

    // VanTrinhNamDataBaseHelper vanTrinhNamDataBaseHelper = new
    // VanTrinhNamDataBaseHelper(this);
    // Bundle mBundle =getIntent().getExtras().getBundle("Bundle");
    // tv_ngaySinhDuongLich.setText(mBundle.getString("NGAY") + " - " +
    // mBundle.getString("THANG") + " - " + mBundle.getString("NAM"));
    // Calendar calendar = Calendar.getInstance();
    // CalendarUtil calendarUtil = new CalendarUtil();
    // int[] convert =
    // calendarUtil.convertSolar2Lunar(Integer.parseInt(mBundle.getString("NGAY")),
    // Integer.parseInt(mBundle.getString("THANG")),
    // Integer.parseInt(mBundle.getString("NAM")), 7);
    // calendar.set(Calendar.DAY_OF_MONTH, convert[0]);
    // calendar.set(Calendar.MONTH, convert[1] - 1);
    // calendar.set(Calendar.YEAR, convert[2]);
    //		Toast.makeText(getApplicationContext(),
    //				NguHanhNgayTotFragment.thongtin, Toast.LENGTH_LONG).show();
    //		String str = NguHanhNgayTotFragment.thongtin;
    //		html = "<html><body><font color ='#000000'" + NguHanhNgayTotFragment.thongtin
    //				+ "</font></body></html>";
    wv_ketqua_nhnt.getSettings().setJavaScriptEnabled(true);
    wv_ketqua_nhnt.getResources().getDimensionPixelSize(R.dimen.text_size_large);
    wv_ketqua_nhnt.loadDataWithBaseURL(
        null, NguHanhNgayTotFragment.thongtin, "text/html", "utf-8", null);
    // wv_ketqua_vantrinhnam.setBackgroundColor(Color.BLACK);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
      wv_ketqua_nhnt.setAlpha(0.7f);
    }
  }
  @Override
  protected void onResume() {
    checkGooglePlayServices();

    if (adView != null) adView.resume();

    super.onResume();
  }