android应用中插入admob广告
生活随笔
收集整理的這篇文章主要介紹了
android应用中插入admob广告
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Step One? 登陸admob,注冊用戶
????? 直接登陸http://www.admob.com/,用google的賬號登陸
?
Step Two 登陸admob后,在站點和應用程序選項中
???? 選擇并添加android應用
??? 注意:在生成好應用程序后,設置應用程序廣告設置,同時記錄一下發布者ID: 11119a2c6ff2759?
?
Step Three 下載admob的sdk
??? 下載路徑:http://code.google.com/intl/zh-CN/mobile/ads/download.html
?
Step Four 解壓SDK ,應用程序加載sdk中的GoogleAdMobAdsSdk-4.1.1.jar
?
Step Five 在應用中加入廣告(代碼方式):
- ???? 在AndroidManifest.xml 文件中???
?????????????? 加入:
<activity android:name="com.google.ads.AdActivity"android:configChanges="keyboard|keyboardHidden|orientation"
/>
//權限部分:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- ????? 界面中設置加入廣告的空間容器 <LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:minHeight="60px"
android:id="@+id/mainLayout"
android:orientation="vertical">
</LinearLayout> - 在Activity中代碼設置廣告
???????
/** Called when the activity is first created. */private AdView adView;
// Create the adView
adView = new AdView(this, AdSize.BANNER, "a14e9a2c6ff2759");
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad a
adView.loadAd(new AdRequest());
?
Step Six: 在Proguard-project.txt文件中加入如下代碼。(否則將不顯示廣告)。如果沒有此文件,則不必執行此步驟。
-dontwarn com.google.ads.**
結束!
轉載于:https://www.cnblogs.com/4-312/p/3368468.html
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的android应用中插入admob广告的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于商业后台系统
- 下一篇: Hibernate级联操作 注解