Admob + Phonegap在Android 2.1上不起作用

时间:2013-04-10 09:49:28

标签: android cordova admob

我已成功将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" /> 

Project.properties

target=android-13

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

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

由于

0 个答案:

没有答案