Java Code Examples for com.google.android.gms.ads.AdRequest

The following are top voted examples for showing how to use com.google.android.gms.ads.AdRequest. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Udacity_Gradle   File: MainActivityFragment.java   Source Code and License 8 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_main, container, false);

    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(AdRequest.DEVICE_ID_EMULATOR)
            .build();
    mAdView.loadAd(adRequest);
    return root;

}
 
Example 2
Project: 1946   File: GooglePlayServicesExtension.java   Source Code and License 6 votes vote down vote up
public void GoogleMobileAds_LoadInterstitial()
{
	RunnerActivity.ViewHandler.post( new Runnable() {
   	public void run() 
   	{
		if(interstitialAd==null)
			initInterstitial();
			
		AdRequest.Builder builder = new AdRequest.Builder();
		builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
		if( bUseTestAds)
			builder.addTestDevice(TestDeviceId);
		AdRequest adRequest = builder.build();

		// Load the interstitial ad.
		interstitialAd.loadAd(adRequest);
	}});
}
 
Example 3
Project: Ad-Mob   File: SecondActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_second);
    mInterstitialAd = new InterstitialAd(this);

    // set the ad unit ID
    mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));

    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice("DCAB007CDB3101E631F092966F546CC2")
            .build();

    // Load ads into Interstitial Ads
    mInterstitialAd.loadAd(adRequest);

    mInterstitialAd.setAdListener(new AdListener() {
        public void onAdLoaded() {
            showInterstitial();
        }
    });
}
 
Example 4
Project: Perfect-Day   File: MoreInfoFragment.java   Source Code and License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mView = inflater.inflate(R.layout.more_info_fragment, container, false);
    ButterKnife.bind(this, mView);
    auth.getCurrentUser();
    Uri photoUrl = auth.getCurrentUser().getPhotoUrl();
    Glide.with(this).load(photoUrl).into(imageView);
    String strMeatFormat = getResources().getString(R.string.welcome_format);
    String strMeatMsg = String.format(strMeatFormat, auth.getCurrentUser().getDisplayName());
    mProfileName.setText(strMeatMsg);
    adView = (AdView) mView.findViewById(R.id.adView);
    AdRequest builder = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
    adView.loadAd(builder);
    return mView;
}
 
Example 5
Project: text_converter   File: AdsManager.java   Source Code and License 6 votes vote down vote up
public static void showFullScreenAdsIfRequired(final StateActivity activity) {
    if (Premium.isPremiumUser(activity)) return;
    final InterstitialAd interstitialAd = new InterstitialAd(activity.getApplicationContext());
    interstitialAd.setAdUnitId(AdConstants.AdUnitId.AD_UNIT_ID_INTERSTITIAL);
    AdRequest.Builder request = new AdRequest.Builder();
    if (BuildConfig.DEBUG) {
        request.addTestDevice(TEST_DEVICE_ID);
    }
    interstitialAd.loadAd(request.build());
    interstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            if (!activity.isFinishing() && activity.isActivityVisible()) {
                interstitialAd.show();
            }
        }
    });
}
 
Example 6
Project: CuYemek   File: CafeteriasFragment.java   Source Code and License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_cafeterias, container, false);
    ButterKnife.bind(this, view);

    mInterstitialAd = new InterstitialAd(getContext());
    mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
    AdRequest adRequest = new AdRequest.Builder().build();
    mInterstitialAd.loadAd(adRequest);

    CustomListAdaptor customListAdaptor = new CustomListAdaptor(getContext(), Arrays.asList(getResources().getStringArray(R.array.cafeterias)));
    lvCafeterias.setAdapter(customListAdaptor);

    lvCafeterias.animate().setDuration(500);

    return view;
}
 
Example 7
Project: MKAPP   File: ActivityMain.java   Source Code and License 6 votes vote down vote up
private void enableAds() {
    RelativeLayout rlAd = (RelativeLayout) findViewById(R.id.rlAd);
    LinearLayout llAd = (LinearLayout) findViewById(R.id.llAd);
    final AdView adView = (AdView) findViewById(R.id.adView);

    rlAd.setVisibility(View.VISIBLE);
    llAd.setVisibility(View.VISIBLE);

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            try {
                AdRequest adRequest = new AdRequest.Builder()
                        .addTestDevice(getString(R.string.ad_test_device_id))
                        .build();
                adView.loadAd(adRequest);
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            }
        }
    }, 1000);
}
 
Example 8
Project: WarningSystemWeather-Android-App   File: ListFragment.java   Source Code and License 6 votes vote down vote up
private void showAds() {
//        mInterstitialAd = new InterstitialAd(getActivity());


        // request the ad
        if (!mInterstitialAd.isLoaded()) {
            Log.d(TAG, "isLoaded: " + String.valueOf(mInterstitialAd.isLoaded()));
            AdRequest ar = new AdRequest.Builder().build();
            mInterstitialAd.loadAd(ar);
        }

        // show the ad
        Log.d(TAG, "showAds: isItTimeToShowAds" + String.valueOf(isItTimeToShowAds));
        if (isItTimeToShowAds % 3 == 0) {
            if (mInterstitialAd.isLoaded()) {
                mInterstitialAd.show();
            }
        }

        ++isItTimeToShowAds;
        Log.d(TAG, "showAds: isItTimeToShowAds" + String.valueOf(isItTimeToShowAds));
    }
 
Example 9
Project: arrispwgen-android   File: MainActivity.java   Source Code and License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AndroidThreeTen.init(this);
    start_date = LocalDate.now();
    end_date = LocalDate.now();
    seed = DEFAULT_SEED;
    setContentView(R.layout.activity_main);

    // 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);

    potd_list_view = (ListView) findViewById(R.id.potd_list);

    generate_potd_list();
}
 
Example 10
Project: CodeInPython   File: quiz15Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_quiz15, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)view.findViewById(R.id.adViewques15);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);



    return view;
}
 
Example 11
Project: CodeInPython   File: quiz5Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_quiz5, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)view.findViewById(R.id.adViewques5);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);

    return  view;
}
 
Example 12
Project: CodeInPython   File: quiz9Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_quiz9, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)view.findViewById(R.id.adViewques9);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);

    return view;
}
 
Example 13
Project: CodeInPython   File: quiz3Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v =  inflater.inflate(R.layout.fragment_quiz3, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)v.findViewById(R.id.adViewques3);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);

    return v;
}
 
Example 14
Project: CodeInPython   File: quiz10Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_quiz10, container, false);


    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)view.findViewById(R.id.adViewques10);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);


    return view;
}
 
Example 15
Project: CodeInPython   File: quiz2Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_quiz2, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)v.findViewById(R.id.adViewques2);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);

    return v;
}
 
Example 16
Project: CodeInPython   File: quiz4Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_quiz4, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)view.findViewById(R.id.adViewques4);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);

    return view;
}
 
Example 17
Project: CodeInPython   File: quiz14Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_quiz14, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)view.findViewById(R.id.adViewques14);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);



    return view;
}
 
Example 18
Project: CodeInPython   File: quiz7Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_quiz7, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)view.findViewById(R.id.adViewques7);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);

    return view;
}
 
Example 19
Project: CodeInPython   File: quiz6Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_quiz6, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)view.findViewById(R.id.adViewques6);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);

    return view;
}
 
Example 20
Project: CodeInPython   File: quiz8Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_quiz8, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)v.findViewById(R.id.adViewques8);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);

    return v;
}
 
Example 21
Project: CodeInPython   File: quiz11Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_quiz11, container, false);

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)view.findViewById(R.id.adViewques11);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);



    return view;
}
 
Example 22
Project: CodeInPython   File: quiz1Fragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment

    View v = inflater.inflate(R.layout.fragment_quiz1, container, false);
    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)v.findViewById(R.id.adViewques1);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);

    return v;
}
 
Example 23
Project: CodeInPython   File: FutureFragment.java   Source Code and License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    //ca-app-pub-2683690631160044/9215612617
    View view = inflater.inflate(R.layout.fragment_future, container, false);
    TextView textView = (TextView)view.findViewById(R.id.pythonfuture);
    String str = getResources().getString(R.string.applications);
    //noinspection deprecation
    textView.setText(Html.fromHtml(str));

    String android_id = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    String deviceId = md5(android_id).toUpperCase();
    Log.i("device id=",deviceId);
    AdView adView = (AdView)view.findViewById(R.id.adViewFuture);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(deviceId)
            .build();
    adView.loadAd(adRequest);


    return view;
}
 
Example 24
Project: GodotAds   File: AdMob.java   Source Code and License 6 votes vote down vote up
private void requestNewRewardedVideo() {
	if (_config == null) { return; }

	AdRequest.Builder adRB = new AdRequest.Builder();

	if (BuildConfig.DEBUG) {
		adRB.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
		adRB.addTestDevice(Utils.getDeviceId(activity));
	}

	String ad_unit_id = _config.optString("RewardedVideoAdId", "");

	if (ad_unit_id.length() <= 0) {
		Utils.d("AdMob:RewardedVideo:UnitId:NotProvided");
		ad_unit_id = activity.getString(R.string.rewarded_video_ad_unit_id);
	}

	mrv.loadAd(ad_unit_id, adRB.build());
}
 
Example 25
Project: Build-it-Bigger   File: MainFragment.java   Source Code and License 6 votes vote down vote up
private void setUpAds() {
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);
    interstitialAd = new InterstitialAd(getContext());
    interstitialAd.setAdUnitId(interstitialAdUnitId);
    interstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            super.onAdFailedToLoad(i);
            requestNewInterstitial();
        }

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

        @Override
        public void onAdOpened() {
            super.onAdOpened();
            requestNewInterstitial();
        }
    });
    requestNewInterstitial();
}
 
Example 26
Project: SnakeWear   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void initAds() {
    MobileAds.initialize(this, "ca-app-pub-2757743767659351~9555852028");
    //MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713"); // Test


    bigAd = new InterstitialAd(this);
    bigAd.setAdUnitId("ca-app-pub-2757743767659351/2179020563");
    bigAd.loadAd(new AdRequest.Builder().build());

    adTop = findViewById(R.id.adViewTop);
    adBottom = findViewById(R.id.adViewBottom);
    adBottom.loadAd(new AdRequest.Builder().build());
    adTop.loadAd(new AdRequest.Builder().build());
}
 
Example 27
Project: Say_it   File: SettingsFragment.java   Source Code and License 5 votes vote down vote up
private void loadRewardedVideoAd() {
    Bundle extras = new Bundle();
    extras.putBoolean("is_designed_for_families", true);

    mRewardedVideoAd.loadAd(getResources().getString(R.string.ad_unit_id_rewarded_donation),
            new AdRequest.Builder()
                    .addTestDevice(getString(R.string.test_device_oneplus_3))
                    .addTestDevice(getString(R.string.test_device_honor_6))
                    .addTestDevice(getString(R.string.test_device_htc_one_m8))
                    .addNetworkExtrasBundle(AdMobAdapter.class, extras)
                    .tagForChildDirectedTreatment(true)
                    .build());
}
 
Example 28
Project: justintrain-client-android   File: Ads.java   Source Code and License 5 votes vote down vote up
public static void initializeAds(Context context, NativeExpressAdView adView) {
    MobileAds.initialize(context, "ca-app-pub-8963908741443055~4285788324");
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
            .addTestDevice("EF67DDDDDDD0896B1B02876D927AC309")  // An example device ID
            .build();
    Log.d("initializeAds: ", adView.getAdUnitId());
    adView.loadAd(adRequest);
}
 
Example 29
Project: justintrain-client-android   File: Ads.java   Source Code and License 5 votes vote down vote up
public static void initializeAds(Context context, AdView adView) {
    MobileAds.initialize(context, "ca-app-pub-8963908741443055~4285788324");
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
            .addTestDevice("EF67DDDDDDD0896B1B02876D927AC309")  // An example device ID
            .build();
    Log.d("initializeAds: ", adView.getAdUnitId());
    adView.loadAd(adRequest);
}
 
Example 30
Project: TibetanPersonalityTest   File: Result.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_result);

    sp = PreferenceManager.getDefaultSharedPreferences(this);

    adView = (AdView) findViewById(R.id.avViewr);
    tv1 = (TextView) findViewById(R.id.tv1);
    tv2 = (TextView) findViewById(R.id.tv2);
    tv3 = (TextView) findViewById(R.id.tv3);

    Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
    toolbar.setTitle("Result");
    setSupportActionBar(toolbar);

    displayAnswer1();
    displayAnswer2();
    displayAnswer3();

    initAds();

    mInterAd = new InterstitialAd(this);
    mInterAd.setAdUnitId(getResources().getString(R.string.finish_inter_ad_id));
    mInterAd.loadAd(new AdRequest.Builder().build());
    mInterAd.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            super.onAdClosed();
            finish();
        }
    });

}
 
Example 31
Project: TibetanPersonalityTest   File: Result.java   Source Code and License 5 votes vote down vote up
private void initAds() {
    AdRequest adRequest = new AdRequest.Builder()
            .build();

    // Start loading the ad in the background.
    adView.loadAd(adRequest);
}
 
Example 32
Project: Ships   File: Utils.java   Source Code and License 5 votes vote down vote up
public static void loadAd(final View view){
	final Builder builder = new AdRequest.Builder();		
	builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR); // Emulator
	
	// Add test devices
	final String[] testDevices = view.getContext().getString(R.string.testDevices).split(",");		
    for (String testDevice:testDevices){
    	builder.addTestDevice(testDevice);
    	
    }
    
    final AdView adView = (AdView) view.findViewById(R.id.adView);
    adView.loadAd(builder.build());
}
 
Example 33
Project: GodotFireBase   File: AdMob.java   Source Code and License 5 votes vote down vote up
private void requestNewRewardedVideo(RewardedVideoAd mrv, String unitid) {
	Utils.d("AdMob:Loading:RewardedAd:For: "+unitid);
	AdRequest.Builder adRB = new AdRequest.Builder();

	if (BuildConfig.DEBUG) {
		adRB.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
		adRB.addTestDevice(Utils.getDeviceId(activity));
	}

	mrv.loadAd(unitid, adRB.build());
}
 
Example 34
Project: GodotFireBase   File: AdMob.java   Source Code and License 5 votes vote down vote up
private void requestNewInterstitial() {
	AdRequest.Builder adRB = new AdRequest.Builder();

	if (BuildConfig.DEBUG) {
		adRB.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
		adRB.addTestDevice(Utils.getDeviceId(activity));
	}

	AdRequest adRequest = adRB.build();

	mInterstitialAd.loadAd(adRequest);
}
 
Example 35
Project: CodeWatch   File: DashboardFragment.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_dashboard, container, false);
    ButterKnife.bind(this, rootView);
    Icepick.restoreInstanceState(this, savedInstanceState);

    context = getActivity();
    setContext(context);
    setChartColors(chartColors);

    if (savedInstanceState == null) {
        firebaseUid = CacheUtils.getFirebaseUserId(context);
    }
    FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
    statsDatabaseRef = firebaseDatabase.getReference().child("users").child(firebaseUid).child("stats");
    projectsDatabaseRef = firebaseDatabase.getReference().child("users").child(firebaseUid).child("timeSpentOnProjects");

    setUpActivityChart();
    setListeners();
    swipeRefreshLayout.setRefreshing(true);

    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);

    if (scrollPosition != null && scrollView != null) {
        scrollView.post(new Runnable() {
            @Override
            public void run() {
                scrollView.scrollTo(0, scrollPosition);
            }
        });
    }
    return rootView;
}
 
Example 36
Project: Calendouer   File: CelebrityActivity.java   Source Code and License 5 votes vote down vote up
private void initAd() {
    ratingUs.setVisibility(View.GONE);
    AdRequest request = new AdRequest.Builder()
            .addTestDevice("43FE98603DD8DD9E449808D85C7DBD45")
            .build();
    adView.loadAd(request);
    adView.setVisibility(View.VISIBLE);
}
 
Example 37
Project: Calendouer   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void initAd() {
    ratingUs.setVisibility(View.GONE);
    AdRequest request = new AdRequest.Builder()
            .addTestDevice("43FE98603DD8DD9E449808D85C7DBD45")
            .build();
    adView.loadAd(request);
    adView.setVisibility(View.VISIBLE);
}
 
Example 38
Project: BookED   File: NearbyBooks.java   Source Code and License 5 votes vote down vote up
private void requestNewInterstitial() {
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
            .addTestDevice("19958886412D28A5FFC7BA20F66C6FF5")
            .build();
    mInterstitialAd.loadAd(adRequest);

}
 
Example 39
Project: Udacity_Gradle   File: MainActivityFragment.java   Source Code and License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_main, container, false);

    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(AdRequest.DEVICE_ID_EMULATOR)
            .build();
    mAdView.loadAd(adRequest);
    return root;
}
 
Example 40
Project: ascii_generate   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void createAdInterstitial() {
    if (!BuildConfig.IS_PREMIUM_USER || hasPremiumApp()) {
        //create ad
        interstitialAd = new InterstitialAd(this);
        if (BuildConfig.DEBUG) {
            interstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
        } else {
            interstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));
        }
        interstitialAd.loadAd(new AdRequest.Builder().build());
    }
}
 
Example 41
Project: ascii_generate   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void loadAdView() {
    if (BuildConfig.IS_PREMIUM_USER || hasPremiumApp()) {
        findViewById(R.id.card_ad_view).setVisibility(View.GONE);
        findViewById(R.id.btn_remove_ads).setVisibility(View.GONE);
        return;
    }
    mAdView = (NativeExpressAdView) findViewById(R.id.native_ad_view);
    if (mAdView != null) {
        mAdView.loadAd(new AdRequest.Builder().build());
    }
}
 
Example 42
Project: ascii_generate   File: AdBannerActivity.java   Source Code and License 5 votes vote down vote up
protected void loadAdViewIfNeed() {
    try {
        mAdView = (AdView) findViewById(R.id.ad_view);
        if (mAdView != null) {
            if (BuildConfig.IS_PREMIUM_USER || hasPremiumApp()) {
                mAdView.setVisibility(View.GONE);
            } else {
                mAdView.loadAd(new AdRequest.Builder().build());
            }
        }
    } catch (Exception e) {
        //class cast
    }
}
 
Example 43
Project: ascii_generate   File: AdBannerActivity.java   Source Code and License 5 votes vote down vote up
protected void loadNativeAd() {
    try {
        mNativeExpressAdView = (NativeExpressAdView) findViewById(R.id.native_ad_view);
        if (mNativeExpressAdView != null) {
            if (BuildConfig.IS_PREMIUM_USER) {
                mNativeExpressAdView.setVisibility(View.GONE);
            } else {
                mNativeExpressAdView.loadAd(new AdRequest.Builder().build());
            }
        }
    } catch (Exception e) {

    }
}
 
Example 44
Project: MovieGuide   File: ActivityUtils.java   Source Code and License 5 votes vote down vote up
/**
 * Show the AdMob banner.
 * https://firebase.google.com/docs/admob/android/quick-start
 * @param activity activity
 */
public static void showAdMobBanner(final AppCompatActivity activity) {
    // Load an ad into the AdMob banner view.
    AdView adView = (AdView) activity.findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);
}
 
Example 45
Project: easyfilemanager   File: AdWrapper.java   Source Code and License 5 votes vote down vote up
private void showAd(){
    if(isInEditMode()){
        return;
    }
    //Fixes GPS AIOB Exception
    try {
        if(null != mAdView){
            mAdView.loadAd(new AdRequest.Builder().build());
        }
    } catch (Exception e){
        CrashReportingManager.logException(e);
    }
}
 
Example 46
Project: prebid-mobile-android   File: DFPInterstitialFragment.java   Source Code and License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    root = inflater.inflate(R.layout.fragment_interstitial, null);
    // interstitial set up
    mPublisherInterstitialAd = new PublisherInterstitialAd(getContext());
    mPublisherInterstitialAd.setAdUnitId(Constants.DFP_INTERSTITIAL_ADUNIT_ID_FULLSCREEN);
    mPublisherInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdFailedToLoad(int i) {
            super.onAdFailedToLoad(i);
            if (i == AdRequest.ERROR_CODE_INTERNAL_ERROR) {
                LogUtil.e("DFP", "Interstitial Ad failed to load internal error");
            } else if (i == AdRequest.ERROR_CODE_INVALID_REQUEST) {
                LogUtil.e("DFP", "Interstitial Ad failed to load internal error");
            } else if (i == AdRequest.ERROR_CODE_NETWORK_ERROR) {
                LogUtil.e("DFP", "Interstitial Ad failed to load network error");
            } else if (i == AdRequest.ERROR_CODE_NO_FILL) {
                LogUtil.e("DFP", "Interstitial Ad failed to load no fill");
            }
        }

        @Override
        public void onAdLoaded() {
            super.onAdLoaded();
            mPublisherInterstitialAd.show();
        }
    });
    request = new PublisherAdRequest.Builder().build();
    Button btnLoad = (Button) root.findViewById(R.id.loadInterstitial);
    btnLoad.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            loadInterstitial(v);
        }
    });
    return root;
}
 
Example 47
Project: editor-sql   File: AdMobView.java   Source Code and License 5 votes vote down vote up
public void loadAdMob() {
    setupAdMobLayout(View.VISIBLE, 50);
    mAdBg.setVisibility(View.VISIBLE);
    if (mAdView != null) {
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
        mAdView.setAdListener(FeViewUtils.getAdMobClick(mAdBg));
    }
}
 
Example 48
Project: MyNotes   File: NoteDetailActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_note_detail);

    ButterKnife.bind(this);

    activity = this;

    topToolbar.setTitle(R.string.app_name);
    setSupportActionBar(topToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    note = getIntent().getParcelableExtra(Note.NOTE_PARCE);

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    dbRefCategorie = database.getReference(CheckLoginActivity.user.getUid()).child(FirebaseContract.CATEGORY_CHILD);
    dbRef = database.getReference(CheckLoginActivity.user.getUid()).child(FirebaseContract.NOTES_CHILD).child(note.getId());

    setNoteDetail();

    if(Utility.isInternetConnection(this)) {
        AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();

        mAdView.loadAd(adRequest);
    }
}
 
Example 49
Project: chat-sdk-android-push-firebase   File: ChatSDKMainActivity.java   Source Code and License 5 votes vote down vote up
public void showInterstitial() {
    // Show the ad if it's ready. Otherwise toast and restart the game.
    if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
        mInterstitialAd.show();
    } else {
        if (!mInterstitialAd.isLoading() && !mInterstitialAd.isLoaded()) {
            AdRequest adRequest = new AdRequest.Builder().build();
            mInterstitialAd.loadAd(adRequest);
        }
    }
}
 
Example 50
Project: Tower-Defense-Galaxy   File: AndroidLauncher.java   Source Code and License 5 votes vote down vote up
@Override
public void showBanner(final boolean show) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            banner.loadAd(new AdRequest.Builder().build());
            banner.setVisibility(show ? 0 : 4);
        }
    });
}
 
Example 51
Project: Tower-Defense-Galaxy   File: AndroidLauncher.java   Source Code and License 5 votes vote down vote up
@Override
public void showVideoAd() {

    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (rewardVideo.isLoaded())
                rewardVideo.show();
            else {
                rewardVideo.loadAd("ca-app-pub-9741625146217992/5189319253", new AdRequest.Builder().build());
                loadingAd = true;
            }
        }
    });
}
 
Example 52
Project: IdealMedia   File: NavigationActivity.java   Source Code and License 5 votes vote down vote up
private void requestInterstitial() {
    if (Settings.PREMIUM || hasPremiumPurchase())
        return;

    if (!Settings.INTERSTITIAL_ENABLED)
        return;

    Date lastInterstitialDate = new Date(PreferenceManager.getDefaultSharedPreferences(this).getLong(getString(R.string.key_interstitial_date), 0));
    if (lastInterstitialDate.getTime() + 1000 * 60 * 60 * 24 * 7 < new Date().getTime()) {
        interstitial = new InterstitialAd(this);
        interstitial.setAdUnitId(getString(R.string.admob_interstitial));
        AdRequest adRequest = new AdRequest.Builder().build();
        interstitial.loadAd(adRequest);
    }
}
 
Example 53
Project: KernelAdiutor-Mod   File: AdNativeExpress.java   Source Code and License 5 votes vote down vote up
private void loadNativeAd(int width, float deviceDensity) {
    float adWidth = width / deviceDensity;
    if (adWidth > MAX_WIDTH) adWidth = MAX_WIDTH;
    mNativeExpressAdView.setAdSize(new AdSize((int) adWidth, MIN_HEIGHT));
    mNativeLoading = true;
    mNativeExpressAdView.loadAd(new AdRequest.Builder().build());
}
 
Example 54
Project: anitrend-app   File: MangaLinksFragment.java   Source Code and License 5 votes vote down vote up
public void updateUI(){
    /*Populate all the views*/
    if(model.getList_stats() != null) {
        mCompleted.setText(model.getList_stats().getCompleted());
        mOnHold.setText(model.getList_stats().getOn_hold());
        mDroped.setText(model.getList_stats().getDropped());
        mPlanningToRead.setText(model.getList_stats().getPlan_to_read());
        mReading.setText(model.getList_stats().getReading());
    }
    if(model.getRankings() != null && model.getRankings().size() > 0) {
        mRankingAdapter = new SeriesRankingAdapter(model.getRankings(), this);
        mRankingRecycler.setAdapter(mRankingAdapter);
    }
    expressAdView.loadAd((new AdRequest.Builder().build()));
}
 
Example 55
Project: admob-rewarded-video   File: MainActivity.java   Source Code and License 5 votes vote down vote up
private void startGame() {
    // Hide the retry button and start the timer.
    mRetryButton.setVisibility(View.INVISIBLE);
    mShowVideoButton.setVisibility(View.INVISIBLE);
    createTimer(COUNTER_TIME);
    mGamePaused = false;
    mGameOver = false;

    mRewardedVideoAd.loadAd(getString(R.string.ad_unit_id), new AdRequest.Builder().build());
}
 
Example 56
Project: BTNotifierAndroid   File: SettingsActivity.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);

    mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
            .addTestDevice("E9DEB34031182776A4E765DCEF19F10D")  // My phone
            .addTestDevice("5C195A4AE6121C0D42702AAAE118DC01")
            .build();
    mAdView.loadAd(adRequest);


    try {
        SslUtils.generateSelfSignedCertificate();
    } catch (Exception e) {
        Log.e(TAG, "Unable to secure network connection. Certificate creation failed", e) ;
        Toast.makeText(context, "Unable to secure network connection. Certificate creation failed", Toast.LENGTH_SHORT).show();
        throw new RuntimeException();
    }

    android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.settingstoolbar);
    setSupportActionBar(toolbar);

    // Display the fragment as the main content.
    getFragmentManager()
            .beginTransaction()
            .replace(R.id.content_frame, new SettingsFragment())
            .commit();




}
 
Example 57
Project: GodotAds   File: AdMob.java   Source Code and License 5 votes vote down vote up
private void requestNewInterstitial() {
	AdRequest.Builder adRB = new AdRequest.Builder();

	if (BuildConfig.DEBUG) {
		adRB.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
		adRB.addTestDevice(Utils.getDeviceId(activity));
	}

	AdRequest adRequest = adRB.build();

	mInterstitialAd.loadAd(adRequest);
}
 
Example 58
Project: Matrix-Calculator-for-Android   File: ViewCreatedMatrix.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean isDark = preferences.getBoolean("DARK_THEME_KEY", false);
    if (isDark)
        setTheme(R.style.AppThemeDark);
    else
        setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_created_matrix);
    adCard = (CardView) findViewById(R.id.AdCard);

    if (!((GlobalValues) getApplication()).DonationKeyFound()) {
        AdView mAdView = (AdView) findViewById(R.id.adViewCreatedView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.setAdListener(new AdLoadListener(adCard));
        mAdView.loadAd(adRequest);
    } else {
        ((ViewGroup) adCard.getParent()).removeView(adCard);
    }


    int index = getIntent().getIntExtra("INDEX", -1);


    if (getSupportActionBar() != null && index != (-1))
        getSupportActionBar().setTitle(((GlobalValues) getApplication()).GetCompleteList().get(index).GetName());
    ViewMatrixFragment viewMatrixFragment = new ViewMatrixFragment();
    Bundle bundle = new Bundle();
    bundle.putInt("INDEX", getIntent().getIntExtra("INDEX", -1));
    viewMatrixFragment.setArguments(bundle);
    if (savedInstanceState == null) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.FragmentContainer, viewMatrixFragment, "VIEW_TAG").commit();

    }
}
 
Example 59
Project: Matrix-Calculator-for-Android   File: faqs.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    isDark = preferences.getBoolean("DARK_THEME_KEY", false);
    if (isDark)
        setTheme(R.style.AppThemeDark);
    else
        setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.help_layout);

    adCard = (CardView) findViewById(R.id.AddCardFAQ);
    if (!((GlobalValues) getApplication()).DonationKeyFound()) {
        AdView faqAd = (AdView) findViewById(R.id.adViewFaq);
        AdRequest adRequest = new AdRequest.Builder().build();
        faqAd.setAdListener(new AdLoadListener(adCard));
        faqAd.loadAd(adRequest);

    } else {
        ((ViewGroup) adCard.getParent()).removeView(adCard);
        //remove cardView from main layout
    }

    if (isDark) {
        SetThisColorToCard(ContextCompat.getColor(this, R.color.DarkcolorPrimary));
        SetThisColorToAllQuestions(ContextCompat.getColor(this, R.color.DarkcolorAccent));
    } else {
        SetThisColorToAllQuestions(ContextCompat.getColor(this, R.color.colorAccent));
    }

}
 
Example 60
Project: Matrix-Calculator-for-Android   File: MinorChooser.java   Source Code and License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean isDark = preferences.getBoolean("DARK_THEME_KEY", false);
    if (isDark)
        setTheme(R.style.AppThemeDark);
    else
        setTheme(R.style.AppTheme);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.minor_chooser);


    if (!((GlobalValues) getApplication()).DonationKeyFound()) {
        AdView adView = (AdView) findViewById(R.id.adViewMinor);
        AdRequest request = new AdRequest.Builder().build();
        adView.loadAd(request);
    } else {
        CardView cardView = (CardView) findViewById(R.id.AddCardMinor);
        ((ViewGroup) cardView.getParent()).removeView(cardView);
    }


    TextView textView = (TextView) findViewById(R.id.ViewHints);
    textView.setText(R.string.ViewHints);
    int index = getIntent().getIntExtra("INDEX", -1);
    if (getSupportActionBar() != null && index != (-1))
        getSupportActionBar().setTitle(((GlobalValues) getApplication()).GetCompleteList().get(index).GetName());
    MinorChooserFragment minorChooserFragment = new MinorChooserFragment();
    Bundle bundle = new Bundle();
    bundle.putInt("INDEX", getIntent().getIntExtra("INDEX", -1));
    minorChooserFragment.setArguments(bundle);
    if (savedInstanceState == null) {
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.FragmentContainer2, minorChooserFragment, "MINOR_TAG").commit();
    }

}