admob 问题总结二

下载了“GoogleAdMobAdsSDK-4.0.2.jar”,最新版的admob sdk 发现,最新版有如下变更。包括com.admob.android.ads.AdManager;android:name="com.google.ads.AdActivity"变更。

 

以下是摘自google code 

 

AdMob Publisher Discuss

 

 

 

Hmm yes, you are right:

http://code.google.com/mobile/ads/kb/#whyupgrade

Coming from use of admob-sdk-android_20101109.zip, I now had to
replace

import com.admob.android.ads.AdManager;
import com.admob.android.ads.AdView;

by

import com.google.ads.*;

In the manifest I had to replace

android:name="com.admob.android.ads.AdMobActivity"

by

android:name="com.google.ads.AdActivity"

I had to replace instances of

adView = new AdView(this);

by

adView = new AdView(this, AdSize.BANNER, <ADMOB_PUBLISHER_ID>);

while from the manifest dropping the line

<meta-data android:value=<ADMOB_PUBLISHER_ID>
android:name="ADMOB_PUBLISHER_ID" />

I had to remove use of setPrimaryTextColor() and
setSecondaryTextColor(), but could keep setBackgroundColor().

I had to add new code like AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);

However, I cannot seem to find a good replacement for
AdManager.setTestDevices() to always exclude showing real ads on my
test phones without a need to recompile for a release version? I want
to make adRequest.setTesting(true) dependent on the phone that it is
running on. Using getDeviceId() and hard-coding my own IMEI numbers
does not seem proper. What is the proper way to handle this?

Interestingly, if I look at the LogCat output with the new SDK and
filtering for the LOGTAG "Ads" tag, I still see the exact same unique
test device identifiers, say <my_test_device_ID>, of my phones that I
used in the older SDK with AdManager.setTestDevices(), but now
appearing in LogCat lines like

INFO/Ads(28609): Received ad url: <"url": "http://r.admob.com:80/
ad_source.php?preqs=1&
 ... &isu=<my_test_device_ID>

So how do I now programmatically read this "isu" number to apply
adRequest.setTesting(true) only to my own devices? If this is no
longer possible then I would consider this an oversight in the new
SDK.

Thanks!

On Mar 20, 8:14 pm, Neil <neilb...@gmail.com> wrote:

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值