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

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

一:要求
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平台完美打造用户体验,铸造开发者高收益!