当前位置: 首页>>代码示例>>Java>>正文


Java AdRequest类代码示例

本文整理汇总了Java中com.google.android.gms.ads.AdRequest的典型用法代码示例。如果您正苦于以下问题:Java AdRequest类的具体用法?Java AdRequest怎么用?Java AdRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AdRequest类属于com.google.android.gms.ads包,在下文中一共展示了AdRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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;

}
 
开发者ID:changja88,项目名称:Udacity_Gradle,代码行数:17,代码来源:MainActivityFragment.java

示例2: GoogleMobileAds_LoadInterstitial

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
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);
	}});
}
 
开发者ID:Magicrafter13,项目名称:1946,代码行数:19,代码来源:GooglePlayServicesExtension.java

示例3: onCreate

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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();
        }
    });
}
 
开发者ID:anwarcse12028,项目名称:Ad-Mob,代码行数:23,代码来源:SecondActivity.java

示例4: onCreateView

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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;
}
 
开发者ID:vixir,项目名称:Perfect-Day,代码行数:17,代码来源:MoreInfoFragment.java

示例5: showFullScreenAdsIfRequired

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
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();
            }
        }
    });
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:20,代码来源:AdsManager.java

示例6: onCreateView

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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;
}
 
开发者ID:yusufcakal,项目名称:CuYemek,代码行数:19,代码来源:CafeteriasFragment.java

示例7: enableAds

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
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);
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:24,代码来源:ActivityMain.java

示例8: showAds

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
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));
    }
 
开发者ID:mzdhr,项目名称:WarningSystemWeather-Android-App,代码行数:23,代码来源:ListFragment.java

示例9: onCreate

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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();
}
 
开发者ID:borfast,项目名称:arrispwgen-android,代码行数:19,代码来源:MainActivity.java

示例10: onCreateView

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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;
}
 
开发者ID:akarshsingh9,项目名称:CodeInPython,代码行数:20,代码来源:quiz15Fragment.java

示例11: onCreateView

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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;
}
 
开发者ID:akarshsingh9,项目名称:CodeInPython,代码行数:18,代码来源:quiz5Fragment.java

示例12: onCreateView

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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;
}
 
开发者ID:akarshsingh9,项目名称:CodeInPython,代码行数:18,代码来源:quiz9Fragment.java

示例13: onCreateView

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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;
}
 
开发者ID:akarshsingh9,项目名称:CodeInPython,代码行数:18,代码来源:quiz3Fragment.java

示例14: onCreateView

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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;
}
 
开发者ID:akarshsingh9,项目名称:CodeInPython,代码行数:20,代码来源:quiz10Fragment.java

示例15: onCreateView

import com.google.android.gms.ads.AdRequest; //导入依赖的package包/类
@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;
}
 
开发者ID:akarshsingh9,项目名称:CodeInPython,代码行数:18,代码来源:quiz2Fragment.java


注:本文中的com.google.android.gms.ads.AdRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。