For some reason,StartApp ads are not showing on my application, despite having followed their setup instructions in the pdf they provided on their site.
I implemented callbacks on the showAd()
and loadAd()
methods and noted that ads are received but not shown. I later created a rectangular background on the view where start app Ad would be shown.I noticed the view with my rectangular border is shown when the ad is loaded but their is no ad content inside the view. See attached image.
In the log cat, 'Ad received' is reported but never ' Ad displayed' or 'Ad hidden' messages from my callbacks.
When I click on the Ad view, my app crashed with Array Index out of bounds exception thrown from the StartApp lib.
See images and code snippets.
My Show add runnable:
private Runnable showAdRunnable = new Runnable() {
@Override
public void run() {
/*
WAS HERE BUT STILL COULDNT SHOW
startAppAd.showAd(new AdDisplayListener() {
@Override
public void adHidden(Ad ad) {
Log.d(TAG, "Ad hidden "+ad.getErrorMessage());
}
@Override
public void adDisplayed(Ad ad) {
Log.d(TAG, "Ad displayed "+ad.getErrorMessage());
}
});
*/
startAppAd.loadAd (new AdEventListener() {
@Override
public void onReceiveAd(Ad ad) {
Log.d(TAG, "Ad received "+ad.getErrorMessage());
startAppAd.showAd(new AdDisplayListener() {
@Override
public void adHidden(Ad ad) {
Log.d(TAG, "Ad hidden "+ad.getErrorMessage());
}
@Override
public void adDisplayed(Ad ad) {
Log.d(TAG, "Ad displayed "+ad.getErrorMessage());
}
});
}
@Override
public void onFailedToReceiveAd(Ad ad) {
Log.d(TAG, "Ad not received "+ad.getErrorMessage());
}
});
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
showing = false;
}
};
My onCreate()
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(final Bundle savedInstanceState) {
Log.d(TAG, "onCreate()");
StartAppAd.init(this, "XXXXXXX", "YYYYYYY");
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// initialize the coin image and result text views
initViews();
// initialize the onclick listener
coinImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
tossCoin();
}
});
initSounds();
showing = true;
new Handler().postDelayed(showAdRunnable , 2*1000);
}
tossmyCoin()
method. This is called when the user clicks on the coin image on my app to toss the coin. I want to refresh the Ad every time the user tosses a coin, so I did:
private void tossCoin() {
....
if (!showing) {
showing = true;
new Handler().postDelayed(showAdRunnable , 2*1000);
}
}
How Ad is shown:
When I click on the Ad section, my app crashes and the log cat contains the following:
10-21 01:38:47.851: E/AndroidRuntime(23900): FATAL EXCEPTION: main
10-21 01:38:47.851: E/AndroidRuntime(23900): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
10-21 01:38:47.851: E/AndroidRuntime(23900): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
10-21 01:38:47.851: E/AndroidRuntime(23900): at java.util.ArrayList.get(ArrayList.java:311)
10-21 01:38:47.851: E/AndroidRuntime(23900): at com.startapp.android.publish.banner.banner3d.Banner3D.onTouchEvent(Unknown Source)
10-21 01:38:47.851: E/AndroidRuntime(23900): at android.view.View.dispatchTouchEvent(View.java:3885)
10-21 01:38:47.851: E/AndroidRuntime(23900): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
See Question&Answers more detail:
os