1

我已成功让 Admob 在我的 4.0.4 模拟器和 4.0.4 手机上显示,但是当我运行 2.1 模拟器并在我的 2.1 手机上尝试时,我收到“无网络”错误,但没有任何显示。

04-10 10:33:38.683: I/Ads(256): Network is unavailable.  Aborting ad request.
04-10 10:33:38.693: D/webviewglue(256): nativeDestroy view: 0x73eac0
04-10 10:33:38.693: I/Ads(256): onFailedToReceiveAd(A network error occurred.)
04-10 10:33:38.693: W/webcore(256): Can't get the viewWidth after the first layout

这是我正在使用的代码:

public class MyPhoneGapActivity extends DroidGap {

private Handler mHandler = new Handler();
private AdView adView;
/** Called when the activity is first created. */

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/index.html");

    mHandler.postDelayed(new Runnable() {
        public void run() {
            doStuff();
        }
    }, 5000); 
}
private void doStuff() {
    final String MY_AD_UNIT_ID = "MY_ID";
    AdView adView; 
    // Create the adView 
    adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID); 
    LinearLayout layout = super.root; // this is the only change from the sample 
    // Add the adView to it 
    layout.addView(adView); 
    // Initiate a generic request to load it with an ad 
    adView.loadAd(new AdRequest());
} 

显现:

<uses-sdk android:minSdkVersion="7" 
android:targetSdkVersion="13"/>

  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.INTERNET" />

  <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /> 

项目属性

target=android-13

似乎如果我将 android:configChanges 更改为以下内容,则广告横幅会显示但包含一条消息,说“您必须在 android manifest.xml 中声明了一个带有配置更改的 adActivity。

 <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|" /> 

谢谢

4

0 回答 0