2013-11-23 145 views
1

我試圖實施InMobi廣告,但廣告不顯示。InMobi廣告不會顯示在Android上?

我按照這裏的教程:http://www.inmobi.com/support/integration/23817448/22051163/android-sdk-integration-guide/

這是我的代碼;

interstitial = new IMInterstitial(this, "my_property_id"); 

    interstitial.loadInterstitial(); 

    if (interstitial.getState() ==IMInterstitial.State.READY) 
     interstitial.show(); 

    interstitial.setIMInterstitialListener(new IMInterstitialListener() { 
     public void onShowInterstitialScreen(IMInterstitial arg0) { 
     } 
     @Override 
     public void onLeaveApplication(IMInterstitial arg0) { 
     } 
     @Override 
     public void onDismissInterstitialScreen(IMInterstitial arg0) { 
     } 
     @Override 
     public void onInterstitialLoaded(IMInterstitial arg0) { 
     } 
     @Override 
     public void onInterstitialInteraction(IMInterstitial interstitial, Map<String, String> params) {     
     } 
     @Override 
     public void onInterstitialFailed(IMInterstitial arg0, IMErrorCode arg1) { 
     } 
    }); 

我在想什麼?

回答

-1

沒有問題,他們需要時間出現在您的應用程序。只是給它一些時間。

+0

我已經等了20分鐘,沒有出現 – erdemgc

+0

您是否正確提供的鑰匙? – CodeWarrior

+0

是的,它是正確的 – erdemgc

2

雖然這是一個很晚的回覆,但我希望它能幫助你。首先是定義必要的權限和活動來顯示。對於引薦跟蹤,你必須添加:

<receiver 
     android:name="com.inmobi.commons.analytics.androidsdk.IMAdTrackerReceiver" 
     android:enabled="true" 
     android:exported="true" > 
     <intent-filter> 
      <action android:name="com.android.vending.INSTALL_REFERRER" /> 
     </intent-filter> 
</receiver> 

您還必須添加的InMobi活動,以您的清單:

<activity 
     android:name="com.inmobi.androidsdk.IMBrowserActivity" 
     android:configChanges="keyboardHidden|orientation|keyboard|smallestScreenSize|screenSize" 
     android:hardwareAccelerated="true" /> 

在Java部分,首先你必須初始化的InMobi。這通常在啓動器活動中完成。如果你還沒有初始化,這是你的代碼中缺少的第一件事。第二件事是失蹤的聽衆。插頁式廣告的類應某事像這樣:

public class InterstitialAdActivity extends Activity implements IMInterstitialListener  { 

protected IMInterstitial mIMInterstitialAd; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    InMobi.initialize(this, "ID"); 
    mIMInterstitialAd = new IMInterstitial(this, "ID"); 
    mIMInterstitialAd.setIMInterstitialListener(this); 
    mIMInterstitialAd.loadInterstitial(); 
} 

@Override 
public void onDismissInterstitialScreen(IMInterstitial arg0) { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onInterstitialFailed(IMInterstitial arg0, IMErrorCode arg1) { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onInterstitialInteraction(IMInterstitial arg0, 
     Map<String, String> arg1) { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onInterstitialLoaded(IMInterstitial arg0) { 
    if(mIMInterstitialAd.getState() == State.READY) 
     mIMInterstitialAd.show(); 
} 

@Override 
public void onLeaveApplication(IMInterstitial arg0) { 
    // TODO Auto-generated method stub 

} 

@Override 
public void onShowInterstitialScreen(IMInterstitial arg0) { 
    // TODO Auto-generated method stub 

} 

}