我正在尝试实施InMobi广告,但没有显示广告。

我在这里遵循了教程: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) {
        }
    });


我想念什么?

最佳答案

虽然这是一个很晚的答复,但我希望它能对您有所帮助。首先是定义必要的权限和活动以体现。对于引荐来源跟踪,您必须添加:

<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

}


}

关于android - InMobi广告没有在Android上展示?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20160497/

10-12 02:21