问题
I've integrated InMobi into my Android App and it doesn't fetch any ads when the app is first run (Banner or Interstitial).
If I exit the app and then run it again, everything works - Banner and Interstitial is loaded and the banner is displayed.
If I then either uninstall and re-install the app or simply clear the app's cache (from settings) and then run the app again, I'm back to square one and I get nothing. Please note this follows this pattern exactly, it's not random. Always on first run - no ads, always on subsequent runs, ads.
I should point out (in case this is important), I am in test mode (Set in the InMobi dashboard).
Below is the code I have in onCreate - What am I doing wrong?
The error returned in the call backs is simply An error occured while fetching the ad (For both Banner and Interstitial).
There is no further information and nothing on the InMobi website (that I can see). Any help would be appreciated.
//Initialise Interstitials
InMobi.initialize(this, myInterstitialID);
//Initialise Banners
InMobi.initialize(this, myBannerID);
//Create the banner
imbanner = new IMBanner(this, myBannerID, IMBanner.INMOBI_AD_UNIT_320X50);
//60 second interval refresh
imbanner.setRefreshInterval(60);
//Load the banner
imbanner.loadBanner();
//Callbacks for the banner ads
imbanner.setIMBannerListener(new IMBannerListener() {
@Override
public void onShowBannerScreen(IMBanner arg0) {
Log.v("Inmobi","OnShowBannerScreen");
}
@Override
public void onLeaveApplication(IMBanner arg0) {
Log.v("Inmobi","Leave Application");
}
@Override
public void onDismissBannerScreen(IMBanner arg0) {
Log.v("Inmobi","OnDismissBannerScreen");
}
@Override
public void onBannerRequestFailed(IMBanner banner, IMErrorCode errorCode) {
Log.v("Inmobi","onBannerRequestFailed: "+errorCode);
}
@Override
public void onBannerRequestSucceeded(IMBanner arg0) {
Log.v("Inmobi","onBannerRequestSucceeded");
}
@Override
public void onBannerInteraction(IMBanner arg0, Map<String, String> arg1) { Log.v("Inmobi","onBannerInteraction");
}
});
//Interstitials
inInterstitial = new IMInterstitial(this, myInterstitialID);
inInterstitial.loadInterstitial();
inInterstitial.setIMInterstitialListener(new IMInterstitialListener() {
public void onShowInterstitialScreen(IMInterstitial arg0) {
Log.v("Inmobi", "Interstitial showing");
}
@Override
public void onLeaveApplication(IMInterstitial arg0) {
Log.v("Inmobi", "Interstitial leaving Application");
}
@Override
public void onDismissInterstitialScreen(IMInterstitial arg0) {
Log.v("Inmobi", "Dismissing Interstitial");
inInterstitial.loadInterstitial();
}
@Override
public void onInterstitialLoaded(IMInterstitial arg0) {
Log.v("Inmobi", "Interstitial loaded");
}
@Override
public void onInterstitialInteraction(IMInterstitial interstitial, Map<String, String> params) {
Log.v("Inmobi", "Interstitial interaction");
}
@Override
public void onInterstitialFailed(IMInterstitial arg0, IMErrorCode arg1) {
Log.v("Inmobi", "Interstitial failed: "+arg1);
}
});
回答1:
@zippy is right. This is a known behaviour which we've fixed in the upcoming SDK release (tentatively in the next 10 days).
Disclaimer: I'm from the InMobi team and manage the SDK product for InMobi
回答2:
I am testing inmobi banner ad on genymotion. I faced the same problem. It didn't show anything. Once I closed app and opened again, it showed banner with a message, banner integration successful on the ad itself. But when I tried again after sometime, it didn't show again. I'm using inmobi 5.0.0 sdk.
I am not sure but it seems to be doing one time testing for a particular device id for one banner/ placement ID, I suppose.
来源:https://stackoverflow.com/questions/32486382/inmobi-not-getting-banner-or-interstitials-on-first-run