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 <[email protected]> wrote:

你可能感兴趣的:(admob)