将腾讯 GDT 与中介集成
本指南面向有兴趣将 Google 移动广告中介与 Tencent GDT 搭配使用发布商。该部分将详细介绍如何设置中介适配器以与您当前的 Android 应用搭配使用,以及如何配置其他设置。
前提条件
实用入门指南
以下帮助中心文章提供了有关调解的背景信息:
将腾讯 GDT 添加到您的项目
添加广告联盟适配器和 SDK
从上文链接下载腾讯 GDT SDK 和适配器。
在 Android Studio 中,将适配器和 SDK 文件添加到项目的 libs
文件夹中。确保您的应用级 Gradle 文件包含以下内容:
Kotlin
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar", "*.jar"))))
// ...
}
Groovy
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'])
// ...
}
按照腾讯 GDT 文档中的说明修改 AndroidManifest.xml
文件。
您的应用无需直接调用腾讯 GDT,Google 移动广告 SDK 会调用腾讯 GDT 适配器来代表您提取广告。如有必要,您可以指定任何其他请求参数。本页的其余部分将详细介绍如何向腾讯 GDT 提供更多信息。
使用 activity 实例初始化您的广告对象
在新广告对象(例如 AdView
)的构造函数中,您必须传入类型为 Context
的对象。使用中介时,此 Context
会传递到其他广告联盟。某些广告联盟需要类型为 Activity
且条件更严格的 Context
,并且如果没有 Activity
实例,可能无法投放广告。因此,我们建议在初始化广告对象时传入 Activity
实例,以确保从您的所有中介广告联盟获得一致的体验。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-08。
[null,null,["最后更新时间 (UTC):2025-02-08。"],[[["This guide explains how to integrate Tencent GDT ads into your Android app using Google Mobile Ads mediation."],["Publishers need an existing Android app with the Google Mobile Ads SDK and an AdMob account with configured mediation line items to begin."],["Integration involves adding the Tencent GDT SDK and adapter to your project, configuring the AndroidManifest.xml, and initializing ad objects with an Activity instance."],["Google Mobile Ads SDK handles communication with the Tencent GDT adapter; publishers don't need to directly interact with Tencent GDT."]]],["This guide details how publishers can integrate Tencent GDT with Google Mobile Ads mediation in Android apps. Key actions include downloading the Tencent GDT SDK and adapter, adding them to the project's `libs` folder, and updating the `AndroidManifest.xml` file as per Tencent GDT's instructions. Additionally, it recommends initializing ad objects with an `Activity` instance for broader ad network compatibility. The Google Mobile Ads SDK manages ad requests via the Tencent GDT adapter.\n"]]