您的位置:首页 > 移动开发 > Android开发

google admob 广告插件添加[android]

2014-01-23 14:33 441 查看
1,首先通过eclipse或直接启动android 的SDK Manager.exe,由于google更改了sdk的集成方式,以前是直接下载admob的sdk包,现在需要通过官方的程序更新Google Play Services,该项中集成了admob的广告sdk。参考https://developer.android.com/tools/help/sdk-manager.html

如图:



2,接着利用eclipse导入google_play_services工程,该工程位于<android-sdk>/extras/google/google_play_services目录下。



3,将google_play_services工程中

libs\google-play-services.jar

res\values\version.xml

这两个文件分别拷贝至你的工程的对应目录下。

4,右键google-play-services.jar,选择Build Path->Add to Build Path,添加lib库

5,在AndroidMainifest.xml中<application></application>标签中添加

<activity android:name="com.google.android.gms.ads.AdActivity"
                  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
		<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
6,参见https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals#play,采用代码或布局添加广告条

// Create the adView.
         adView = new AdView(this);
         adView.setAdUnitId(getResources().getString(R.string.ad_unit_id));
         adView.setAdSize(AdSize.BANNER);
         
         LinearLayout layout = (LinearLayout)findViewById(R.id.linerLayout_bot);
         layout.addView(adView);
         // Initiate a generic request.
         AdRequest adRequest = new AdRequest.Builder().build();
         // Load the adView with the ad request.
         adView.loadAd(adRequest);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: