本文整理汇总了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;
}
示例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);
}});
}
示例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();
}
});
}
示例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;
}
示例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();
}
}
});
}
示例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;
}
示例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);
}
示例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));
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}