Android版使用移动广告平台集成Google Mobile Ads SDK教程

一:要求
1.请确保您使用的是最新版本的Android SDK,且编译所针对的至少是Androidv3.2(将project.properties中的target设为android-13)。
2.Google Mobile Ads SDK(Android版)要求使用Android 2.3或更高版本的运行时文件(在AndroidManifest.xml中至少将android:minSdkVersion设为9)。这表示,您可以使用最新版本的Android SDK进行开发,而您的应用仍能在更早版本的Android(最低2.3版)上运行。


二:加入SDK
将Google移动广告加入应用是一个简单的过程:
1.在您的Eclipse工作空间中添加和引用Google Play服务库项目。
2.在AndroidManifest.xml中添加meta-data标记。
3.在清单中声明com.Google.android.gms.ads.AdActivity。
4.在清单中设置网络权限。


<1>添加和引用Google Play服务库项目
a.在Eclipse中右键点击您的应用项目,并选择Properties。
b.选择Android,然后点击Add...。找到Google-play-services_lib项目,然后选择OK以添加Google Play服务库。
c.项目现在即会引用Google Play服务库


<2>添加meta-data标记
Google Play服务要求您在应用的AndroidManifest.xml的元素内添加以下meta-data标记:
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company" android:versionCode="1" android:versionName="1.0">

<application android:icon="@drawable/icon" android:label="@string/app_name"android:debuggable="true">

<meta-data android:name="com.Google.android.gms.version"
android:value="@integer/Google_play_services_version"/>

<activity android:label="@string/app_name" android:name="BannerExample">

<intent-filter>

<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>

      </intent-filter>

    </activity>

  </application>

</manifest>


<3>声明com.Google.android.gms.ads.AdActivity
Mobile Ads SDK要求您在应用的AndroidManifest.xml中声明com.Google.android.gms.ads.AdActivity

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company" android:versionCode="1" android:versionName="1.0">

<application android:icon="@drawable/icon" android:label="@string/app_name"android:debuggable="true">

<meta-data android:name="com.Google.android.gms.version"
android:value="@integer/Google_play_services_version"/>

<activity android:label="@string/app_name" android:name="BannerExample">

<intent-filter>

<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>

</intent-filter>

</activity>

<activity android:name="com.Google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

</application>

</manifest>


<4>设置网络权限
要创建广告请求,必须在清单中声明以下权限:INTERNET

用于访问互联网以发送广告请求。ACCESS_NETWORK_STATE

KeyMob移动广告平台,简称“KeyMob广告”,是为开发者提供精准稳定的SDK,KeyMob平台有横幅广告、插屏广告、积分墙和视频广告等广告形式,KeyMob平台完美打造用户体验,铸造开发者高收益!

转载于:https://my.oschina.net/u/2505907/blog/546093

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值