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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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());
    }
}