Search code examples
androidadsinterstitial

Startapp interstitial ad not showing in onCreate


This is in onCreate:

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    StartAppAd.init(this, "devID", "appID");
    setContentView(R.layout.activity_results);

    startAppAd.showAd();
    startAppAd.loadAd();
}           

And it doesn't show the Ad, but if I change it to:

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    StartAppAd.init(this, "devID", "appID");
    setContentView(R.layout.activity_results);

    new Handler().postDelayed(new Runnable()
    {
        @Override
        public void run()
        {
            startAppAd.showAd();
            startAppAd.loadAd();
        }
    }, 2000);

}

It works. How can I make the ad to display as soon as it is ready?


Solution

  • I got around the problem by simply putting loadAd(); in the onCreate of the previous activity and showAd(); just before my startIntent();.