本文整理汇总了Java中com.google.android.gms.ads.doubleclick.PublisherAdRequest类的典型用法代码示例。如果您正苦于以下问题:Java PublisherAdRequest类的具体用法?Java PublisherAdRequest怎么用?Java PublisherAdRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PublisherAdRequest类属于com.google.android.gms.ads.doubleclick包,在下文中一共展示了PublisherAdRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setupBannerWithWait
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
private void setupBannerWithWait(final int waitTime) {
FrameLayout adFrame = (FrameLayout) root.findViewById(R.id.adFrame2);
adFrame.removeAllViews();
adView2 = new PublisherAdView(getActivity());
adView2.setAdUnitId(Constants.DFP_BANNER_ADUNIT_ID_300x250);
adView2.setAdSizes(new AdSize(300, 250));
adView2.setAdListener(adListener);
adFrame.addView(adView2);
//region PriceCheckForDFP API usage
PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
PublisherAdRequest request = builder.build();
Prebid.attachBidsWhenReady(request, Constants.BANNER_300x250, this, waitTime, this.getActivity());
//endregion
}
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:17,代码来源:DFPBannerFragment.java
示例2: addBannerAds
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
/**
* Create {@link PublisherAdView} and add to container
*
* @param context - android context
* @param container - parent view for add ad view
* @return true if ads has been added
*/
public static boolean addBannerAds(Context context, @Nullable ViewGroup container) {
if (isPremiumUser(context)) {
if (container != null) {
container.setVisibility(View.GONE);
}
return false;
} else {
if (container == null) return false;
container.setVisibility(View.VISIBLE);
PublisherAdView publisherAdView = new PublisherAdView(context);
publisherAdView.setAdSizes(AdSize.SMART_BANNER, AdSize.FLUID);
publisherAdView.setAdUnitId(AdConstants.AdUnitId.AD_UNIT_ID_NATIVE_MAIN_320_50);
PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
if (BuildConfig.DEBUG) builder.addTestDevice(TEST_DEVICE_ID);
publisherAdView.loadAd(builder.build());
container.removeAllViews();
container.addView(publisherAdView);
}
return false;
}
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:30,代码来源:AdsManager.java
示例3: onCreate
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
// Gets the ad view defined in layout/ad_fragment.xml with ad unit ID set in
// values/strings.xml.
mAdView = findViewById(R.id.ad_view);
// 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."
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
// Start loading the ad in the background.
mAdView.loadAd(adRequest);
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:18,代码来源:MyActivity.java
示例4: onActivityCreated
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mNoExclusionsAdView =
getView().findViewById(R.id.no_exclusions_av);
mDogsExcludedAdView =
getView().findViewById(R.id.exclusions_av_dogsexcluded);
mCatsExcludedAdView =
getView().findViewById(R.id.exclusions_av_catsexcluded);
PublisherAdRequest noExclusionsRequest = new PublisherAdRequest.Builder().build();
PublisherAdRequest dogsExcludedRequest = new PublisherAdRequest.Builder()
.addCategoryExclusion(getString(R.string.categoryexclusion_dogscategoryname))
.build();
PublisherAdRequest catsExcludedRequest = new PublisherAdRequest.Builder()
.addCategoryExclusion(getString(R.string.categoryexclusion_catscategoryname))
.build();
mNoExclusionsAdView.loadAd(noExclusionsRequest);
mDogsExcludedAdView.loadAd(dogsExcludedRequest);
mCatsExcludedAdView.loadAd(catsExcludedRequest);
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:24,代码来源:DFPCategoryExclusionFragment.java
示例5: onActivityCreated
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mUsernameEditText = getView().findViewById(R.id.ppid_et_username);
mLoadAdButton = getView().findViewById(R.id.ppid_btn_loadad);
mPublisherAdView = getView().findViewById(R.id.ppid_pav_main);
mLoadAdButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String username = mUsernameEditText.getText().toString();
if (username.length() == 0) {
Toast.makeText(DFPPPIDFragment.this.getActivity(),
"The username cannot be empty", Toast.LENGTH_SHORT).show();
} else {
String ppid = generatePPID(username);
PublisherAdRequest request = new PublisherAdRequest.Builder()
.setPublisherProvidedId(ppid)
.build();
mPublisherAdView.loadAd(request);
}
}
});
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:27,代码来源:DFPPPIDFragment.java
示例6: onActivityCreated
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mSportsSpinner = getView().findViewById(R.id.customtargeting_spn_sport);
mLoadButton = getView().findViewById(R.id.customtargeting_btn_loadad);
mAdView = getView().findViewById(R.id.customtargeting_av_main);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getView().getContext(),
R.array.customtargeting_sports, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSportsSpinner.setAdapter(adapter);
mLoadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PublisherAdRequest adRequest = new PublisherAdRequest.Builder()
.addCustomTargeting(getString(R.string.customtargeting_key),
(String) mSportsSpinner.getSelectedItem())
.build();
mAdView.loadAd(adRequest);
}
});
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:26,代码来源:DFPCustomTargetingFragment.java
示例7: onCreateView
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
@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;
}
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:40,代码来源:DFPInterstitialFragment.java
示例8: setupBannerWithoutWait
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
private void setupBannerWithoutWait() {
FrameLayout adFrame = (FrameLayout) root.findViewById(R.id.adFrame);
adFrame.removeAllViews();
adView1 = new PublisherAdView(getActivity());
adView1.setAdUnitId(Constants.DFP_BANNER_ADUNIT_ID_320x50);
adView1.setAdSizes(new AdSize(320, 50));
adView1.setAdListener(adListener);
adFrame.addView(adView1);
//region PriceCheckForDFP API usage
PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
PublisherAdRequest request = builder.build();
Prebid.attachBids(request, Constants.BANNER_320x50, this.getActivity());
//endregion
adView1.loadAd(request);
}
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:16,代码来源:DFPBannerFragment.java
示例9: onAttachComplete
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
@Override
public void onAttachComplete(Object adObj) {
if (adView2 != null && adObj != null && adObj instanceof PublisherAdRequest) {
adView2.loadAd((PublisherAdRequest) adObj);
Prebid.detachUsedBid(adObj);
}
}
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:8,代码来源:DFPBannerFragment.java
示例10: getBanner
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
private void getBanner(String iu){
final PublisherAdView adView = new PublisherAdView(getContext());
adView.setAdUnitId(iu);
adView.setAdSizes(AdSize.SMART_BANNER);
AdListener mAdListener = new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
}
@Override
public void onAdFailedToLoad(int errorCode) {
super.onAdFailedToLoad(errorCode);
}
@Override
public void onAdLeftApplication() {
super.onAdLeftApplication();
}
@Override
public void onAdOpened() {
super.onAdOpened();
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
bannerContainer.addView(adView);
}
};
adView.setAdListener(mAdListener);
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
adView.loadAd(adRequest);
}
开发者ID:hotmobmobile,项目名称:hotmob-android-sdk,代码行数:36,代码来源:MediationBannerFragment.java
示例11: getPopup
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
private void getPopup(String adCode){
final PublisherInterstitialAd interstitialAd = new PublisherInterstitialAd(getActivity());
interstitialAd.setAdUnitId(adCode);
interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
}
@Override
public void onAdLoaded() {
interstitialAd.show();
}
@Override
public void onAdFailedToLoad(int errorCode) {
}
@Override
public void onAdLeftApplication() {
super.onAdLeftApplication();
}
@Override
public void onAdOpened() {
super.onAdOpened();
}
});
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
interstitialAd.loadAd(adRequest);
}
开发者ID:hotmobmobile,项目名称:hotmob-android-sdk,代码行数:31,代码来源:MediationPopupFragment.java
示例12: startGame
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
private void startGame() {
// Request a new ad if one isn't already loaded, hide the button, and kick off the timer.
if (!mAdIsLoading && !mInterstitialAd.isLoaded()) {
mAdIsLoading = true;
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
mInterstitialAd.loadAd(adRequest);
}
mRetryButton.setVisibility(View.INVISIBLE);
resumeGame(GAME_LENGTH_MILLISECONDS);
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:12,代码来源:MyActivity.java
示例13: onActivityCreated
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mAdView = getView().findViewById(R.id.appevents_av_main);
mAdView.setAppEventListener(new AppEventListener() {
@Override
public void onAppEvent(String name, String data) {
// The DFP ad that this fragment loads contains JavaScript code that sends App
// Events to the host application. This AppEventListener receives those events,
// and sets the background of the fragment to match the data that comes in.
// The ad will send "red" when it loads, "blue" five seconds later, and "green"
// if the user taps the ad.
// This is just a demonstration, of course. Your apps can do much more interesting
// things with App Events.
if (name.equals("color")) {
switch (data) {
case "blue":
mRootView.setBackgroundColor(Color.rgb(0xD0, 0xD0, 0xFF));
break;
case "red":
mRootView.setBackgroundColor(Color.rgb(0xFF, 0xD0, 0xD0));
break;
case "green":
mRootView.setBackgroundColor(Color.rgb(0xD0, 0xFF, 0xD0));
break;
}
}
}
});
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:39,代码来源:DFPAppEventsFragment.java
示例14: onActivityCreated
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// The size for this PublisherAdView is defined in the XML layout as AdSize.FLUID. It could
// also be set here by calling mPublisherAdView.setAdSizes(AdSize.FLUID).
//
// An ad with fluid size will automatically stretch or shrink to fit the height of its
// content, which can help layout designers cut down on excess whitespace.
mPublisherAdView = getView().findViewById(R.id.fluid_av_main);
PublisherAdRequest publisherAdRequest = new PublisherAdRequest.Builder().build();
mPublisherAdView.loadAd(publisherAdRequest);
mChangeAdViewWidthButton = getView().findViewById(R.id.fluid_btn_change_width);
mChangeAdViewWidthButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int newWidth = mAdViewWidths[mCurrentIndex % mAdViewWidths.length];
mCurrentIndex += 1;
// Change the PublisherAdView's width.
ViewGroup.LayoutParams layoutParams = mPublisherAdView.getLayoutParams();
final float scale = getResources().getDisplayMetrics().density;
layoutParams.width = (int) (newWidth * scale + 0.5f);
mPublisherAdView.setLayoutParams(layoutParams);
// Update the TextView with the new width.
mCurrentWidthTextView = getView().findViewById(R.id.fluid_tv_current_width);
mCurrentWidthTextView.setText(
String.format(Locale.getDefault(), "%d dp", newWidth));
}
});
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:33,代码来源:DFPFluidSizeFragment.java
示例15: loadAd
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
/**
* Loads a {@link NativeContentAd} and calls {@link ContentAdViewHolder} methods to
* display its assets or handle failure by hiding the view.
*/
public void loadAd(Context context, ContentAdViewHolder viewHolder) {
synchronized (mSyncObject) {
mViewHolder = viewHolder;
if ((mAdLoader != null) && mAdLoader.isLoading()) {
Log.d(MainActivity.LOG_TAG, "ContentAdFetcher is already loading an ad.");
return;
}
// If an ad previously loaded, reuse it instead of requesting a new one.
if (mContentAd != null) {
mViewHolder.populateView(mContentAd);
return;
}
NativeContentAd.OnContentAdLoadedListener contentAdListener =
new NativeContentAd.OnContentAdLoadedListener() {
public void onContentAdLoaded(NativeContentAd ad) {
mContentAd = ad;
mViewHolder.populateView(mContentAd);
}
};
if (mAdLoader == null) {
mAdLoader = new AdLoader.Builder(context, mAdUnitId)
.forContentAd(contentAdListener)
.withAdListener(new AdListener() {
@Override
public void onAdFailedToLoad(int errorCode) {
mViewHolder.hideView();
Log.e(MainActivity.LOG_TAG,
"Content Ad Failed to load: " + errorCode);
}
}).build();
}
mAdLoader.loadAd(new PublisherAdRequest.Builder().build());
}
}
开发者ID:googlesamples,项目名称:android-ads,代码行数:44,代码来源:ContentAdFetcher.java
示例16: loadBanner
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
public void loadBanner() {
ArrayList<AdSize> adSizes = new ArrayList<AdSize>();
if (this.adSize != null) {
adSizes.add(this.adSize);
}
if (this.validAdSizes != null) {
for (int i = 0; i < this.validAdSizes.length; i++) {
adSizes.add(this.validAdSizes[i]);
}
}
if (adSizes.size() == 0) {
adSizes.add(AdSize.BANNER);
}
AdSize[] adSizesArray = adSizes.toArray(new AdSize[adSizes.size()]);
this.adView.setAdSizes(adSizesArray);
PublisherAdRequest.Builder adRequestBuilder = new PublisherAdRequest.Builder();
if (testDevices != null) {
for (int i = 0; i < testDevices.length; i++) {
adRequestBuilder.addTestDevice(testDevices[i]);
}
}
PublisherAdRequest adRequest = adRequestBuilder.build();
this.adView.loadAd(adRequest);
}
开发者ID:sbugert,项目名称:react-native-admob,代码行数:28,代码来源:RNPublisherBannerViewManager.java
示例17: getExportedViewConstants
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
@Nullable
@Override
public Map<String, Object> getExportedViewConstants() {
final Map<String, Object> constants = new HashMap<>();
constants.put("simulatorId", PublisherAdRequest.DEVICE_ID_EMULATOR);
return constants;
}
开发者ID:sbugert,项目名称:react-native-admob,代码行数:8,代码来源:RNPublisherBannerViewManager.java
示例18: buildRequest
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
private PublisherAdRequest buildRequest(DFBBannerSSParameters ssparm, TargetingParameters targetingParameters) {
PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
if ((ssparm.test_device != null) && (ssparm.test_device.length() > 0)) {
adListener.printToClog("test device " + ssparm.test_device);
builder.addTestDevice(ssparm.test_device);
}
switch (targetingParameters.getGender()) {
case UNKNOWN:
builder.setGender(PublisherAdRequest.GENDER_UNKNOWN);
break;
case FEMALE:
builder.setGender(PublisherAdRequest.GENDER_FEMALE);
break;
case MALE:
builder.setGender(PublisherAdRequest.GENDER_MALE);
break;
}
Bundle bundle = new Bundle();
if (targetingParameters.getAge() != null) {
bundle.putString("Age", targetingParameters.getAge());
}
if (targetingParameters.getLocation() != null) {
builder.setLocation(targetingParameters.getLocation());
}
for (Pair<String, String> p : targetingParameters.getCustomKeywords()) {
bundle.putString(p.first, p.second);
}
builder.addNetworkExtras(new AdMobExtras(bundle));
return builder.build();
}
开发者ID:appnexus,项目名称:mobile-sdk-android,代码行数:36,代码来源:GooglePlayDFPBanner.java
示例19: buildRequest
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
private PublisherAdRequest buildRequest(TargetingParameters targetingParameters) {
PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
switch (targetingParameters.getGender()) {
case UNKNOWN:
builder.setGender(PublisherAdRequest.GENDER_UNKNOWN);
break;
case FEMALE:
builder.setGender(PublisherAdRequest.GENDER_FEMALE);
break;
case MALE:
builder.setGender(PublisherAdRequest.GENDER_MALE);
break;
}
Bundle bundle = new Bundle();
if (targetingParameters.getAge() != null) {
bundle.putString("Age", targetingParameters.getAge());
}
if (targetingParameters.getLocation() != null) {
builder.setLocation(targetingParameters.getLocation());
}
for (Pair<String, String> p : targetingParameters.getCustomKeywords()) {
bundle.putString(p.first, p.second);
}
builder.addNetworkExtras(new AdMobExtras(bundle));
return builder.build();
}
开发者ID:appnexus,项目名称:mobile-sdk-android,代码行数:31,代码来源:GooglePlayDFPInterstitial.java
示例20: getView
import com.google.android.gms.ads.doubleclick.PublisherAdRequest; //导入依赖的package包/类
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
// Get the data item for this position
String item = getItem(position);
// Check if an existing view is being reused, otherwise inflate the view
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.listitem_mediation_banner, parent, false);
}
// Lookup view for data population
TextView adCode = convertView.findViewById(R.id.adcode);
final ViewGroup bannerContainer = convertView.findViewById(R.id.banner_view);
// Populate the data into the template view using the data object
adCode.setText(item);
if (bannerContainer.getChildCount() == 0) {
final PublisherAdView adView = new PublisherAdView(getContext());
adView.setAdUnitId(item);
adView.setAdSizes(AdSize.SMART_BANNER);
AdListener mAdListener = new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
}
@Override
public void onAdFailedToLoad(int errorCode) {
super.onAdFailedToLoad(errorCode);
}
@Override
public void onAdLeftApplication() {
super.onAdLeftApplication();
}
@Override
public void onAdOpened() {
super.onAdOpened();
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
bannerContainer.addView(adView);
}
};
adView.setAdListener(mAdListener);
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
adView.loadAd(adRequest);
}
// Return the completed view to render on screen
return convertView;
}
开发者ID:hotmobmobile,项目名称:hotmob-android-sdk,代码行数:53,代码来源:MediationListAdapter.java
注:本文中的com.google.android.gms.ads.doubleclick.PublisherAdRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论