gpt4 book ai didi

android - 与 "old"AdMob SDK 相比,我们是否应该更喜欢 Google Play 服务中的 AdMob

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:46:41 24 4
gpt4 key购买 nike

我刚刚意识到 Google 将 AdMob 嵌入到了最新的 Google Play 服务中 (4+)

我在想,我应该选择 https://developers.google.com/mobile-ads-sdk/docs/#play 吗?在 https://developers.google.com/mobile-ads-sdk/docs/#android ?因为我没有看到谷歌官方对此持立场。

之所以这么问,是因为我发现 Google Play 服务中的 AdMob 仍然存在很多问题。

这是我的观察。

  1. 使用 Java 代码创建一个智能横幅,并将其放置在 ScrollView 的中间。
  2. 每当智能横幅成功从 Google 服务器获取广告时, ScrollView 将自动滚动以使智能横幅可见。

从我的角度来看,这似乎是一种不受欢迎的行为。这就是为什么我仍然犹豫要不要迁移到新的 Google Play 服务。

可在此处找到演示错误的完整源代码:AdMob from Google Play Services will perform undesired auto scrolling

最佳答案

如果您想集成许多广告 SDK,并且如果他们使用 Google Play 服务作为后端支持来转换广告,并且您还想展示 Admob 横幅广告,那么您应该使用它。

它非常容易使用。只需添加 goole play 服务 lib 项目然后使用

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"

android:id="@+id/linearLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="a1529793ead3391"
ads:adSize="BANNER"/>

</LinearLayout>

现在您可以在要显示的 Activity 中简单地添加以下代码段

 AdView adView = (AdView)findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);

关于android - 与 "old"AdMob SDK 相比,我们是否应该更喜欢 Google Play 服务中的 AdMob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19956048/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com