Admob Interstitials: Closing behaviour

Hello,

i’m using Admob Interstitials. in my apps.

In general there are 2 possibilities of how an user can dismiss the ad:

  1. Click on the back button
  2. Click on the ‘cross’ on the top left

As far as i found out when choosing 1st possiblity only the ad disappears, and the user will be taken to the calling activity.
However if he does option 2 the ad will be dismissed but also the app is closed (homescreen is shown).

Is there any possiblity to always only close the ad (and not the activity / app)?

I have never had this behaviour with option 2, you should verify your code. Don’t you have a finish() in your onResume() or something like that ?

Or you may be calling finish() after presenting the ad (if your doing exit ad or something like that).

No, nothing like this. As far as i see it also only happens in one of my apps, the others seem to work fine.

The code that i use (should show an interstitial on opening of the app):

public class MainActivity extends Activity
{

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

  this.setTitle(GlobalSettings.appName);
  // request interstitial
  requestInterstitialAd(this);

}

public static void requestInterstitialAd(Activity act)
{
// Create the interstitial
interstitial = new InterstitialAd(act, adId);

  // Create ad request
  AdRequest adRequest = new AdRequest();
  
  // add test devices
  adRequest.addTestDevice(adRequest.TEST_EMULATOR);
  // Begin loading your interstitial
  interstitial.loadAd(adRequest);
  // set listener that shows the ad when loaded
  interstitial.setAdListener(new AdListener()
  {
  	@Override
  	public void onReceiveAd(Ad arg0)
  	{
  		if (interstitial.isReady())
  			interstitial.show();
  	}
  	@Override
  	public void onPresentScreen(Ad arg0)
  	{
  		// TODO Auto-generated method stub
  	}
  	@Override
  	public void onLeaveApplication(Ad arg0)
  	{
  		// TODO Auto-generated method stub
  	}
  	@Override
  	public void onFailedToReceiveAd(Ad arg0, ErrorCode arg1)
  	{
  		// TODO Auto-generated method stub
  	}
  	@Override
  	public void onDismissScreen(Ad arg0)
  	{
  		// TODO Auto-generated method stub
  	}
  });

}
}

//EDIT:
ok, i found the problem now:
I had the ‘android:noHistory=“true”’ tag declared in the manifest for this activity.

android:noHistory
Whether or not the activity should be removed from the activity stack and finished (its finish() method called) when the user navigates away from it and it’s no longer visible on screen — “true” if it should be finished, and “false” if not. The default value is “false”.

A value of "true" means that the activity will not leave a historical trace. It will not remain in the activity stack for the task, so the user will not be able to return to it.