那手機上呢,畢竟會想要增加瀏覽量
但是看了很多文章,好像發覺adsense已經把mobile的部份拿掉
應該是因為google要整合環境的關係
所以定位平台是在admob上面,不過好消息是admob已經加入了可以讀取Adsense廣告的選項
且admob在手機平台上面確實發展比較久
要將功能implement進去android系統裡面也很簡單
除了可以用程式方面玩成,也可以直接在xml上面設定
這裡筆者是用程式部份
1.首先你得要去註冊admob
2.然後登入, 點選選單中的『網站與應用程式』下的『新增網站/應用程式』。
3. 選擇『Android 應用程式』
4.填入你的應用程式資料,然後下載admob提供的sdk
5.Adding the SDK JAR
The decompressed SDK consists of a JAR, a javadoc folder and a README.
1. Right click on your app project in Eclipse and choose Properties.

2. Select Java Build Path and the Libraries tab. Then click Add External JARs... to add the Google AdMob Ads JAR.

The five lines of code it takes to add a banner:
- Import com.google.ads.*
- Declare an AdView instance
- Create it, specifying a unit ID—your AdMob publisher ID 記得要輸入自己的admob ID,這樣才會有錢領
- Add the view to the UI
- Load it with an ad
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the adView
AdView adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
// 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
adView.loadAd(new AdRequest());
}
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the adView
AdView adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
// 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
adView.loadAd(new AdRequest());
}
以上,已經很完整描寫如何簡單加入一個ADMOB廣告進入你的程式了
沒有留言:
張貼留言