2011-03-24 22 views
0

我剛剛在Admod上添加了一個新網站,它表現出他們正在使用新的sdk,其中舊版本是admod-sdk- Android和新的GoogleAdMobsdk。 我跟着谷歌示例代碼,除了我設置測試標誌爲true。 起初它出現了,所有人都很興奮,但是當我再次運行它時,它並沒有出現。看起來廣告的出現時間不到一半。如果它不在測試mod中,我知道這樣可以。如果測試標誌是真的,廣告allwys應該出現嗎? 代碼Admob廣告出現時間少於1/2時間,而在測試模式下使用新的admob sdk

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 


    View mCall = findViewById(R.id.call); 
    mCall.setOnClickListener(this); 

    View mAbout = findViewById(R.id.about); 
    mAbout.setOnClickListener(this); 

    View mWhatWeDo = findViewById(R.id.whatwedo); 
    mWhatWeDo.setOnClickListener(this); 

    View mEmail = findViewById(R.id.email); 
    mEmail.setOnClickListener(this); 

    View mMap = findViewById(R.id.map); 
    mMap.setOnClickListener(this); 

    // Create the adView 
    // Create the adView 
    AdView adv = new AdView(this, AdSize.BANNER, "a14d84be1abee56"); 

    // 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(adv); 
    // Initiate a generic request to load it with an ad 
    AdRequest t=new AdRequest(); 
    t.setTesting(true); 
    adv.loadAd(t); 

} 

佈局:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:background="#ff00ffff" 
    android:layout_height="fill_parent" 
    > 
    <LinearLayout 
     android:id="@+id/mainLayout" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 
    </LinearLayout> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/header" 
     android:layout_gravity="center" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="" 
     android:textSize="8px" /> 

    <Button 
     android:id="@+id/about" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="Who we are" 
     android:textStyle="bold" 
     android:textColor="#ffff00ff" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="" 
     android:textSize="6px" /> 

    <Button 
     android:id="@+id/whatwedo" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textColor="#ffff00ff" 
     android:text="What we do" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="" 
     android:textSize="6px" /> 

    <Button 
     android:id="@+id/call" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textColor="#ffff00ff" 
     android:text="Call Us" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="6px" 
     android:text="" /> 

    <Button 
     android:id="@+id/map" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textColor="#ffff00ff" 
     android:text="Driving Directions" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="6px" 
     android:text="" /> 

    <Button 
     android:id="@+id/email" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textColor="#ffff00ff" 
     android:text="Email Us" /> 

</LinearLayot> 

回答

0

我面臨着同樣的問題,也是。新的SDK的行爲方式與舊版本的方式不同。我建議您刪除測試模式,並嘗試在admob報告頁面查看您是否能夠在其中查看您的應用的頁面請求。