I'm using, among other views, a SurfaceView
in my main activity.
The class which extends the SurfaceView
implements also the SurfaceHolder.Callback
with the callback methods:
I'm also using the Google Admob Mobile Ads SDK to show Interstitial
ads.
Now I experience two different behavior starting a child activity started by me and showing an interstitial ad started using the Google Admob SDK.
I use
startActivity(new Intent(getBaseContext(), SettingsActivity.class));
which calls the SurfaceHolder.Callback
methods surfaceDestroyed
and surfaceCreated
once I return to the main activity.
I use
if(_myInterstitialAd.isLoaded())
{
_myInterstitialAd.show();
}
which calls the SurfaceHolder.Callback
methods surfaceChanged
and surfaceChanged
once I return to the main activity. Yes, it calls the surfaceChanged
twice.
With the Android Studio "Layout Inspector" I see that the started interstitial ad is also an Activity (com.google.android.gms.ads.AdActivity
). So I'm really wondering what is when I start my own activities.
Can someone explain how does Google achieve this behavior that only the surfaceChanged
methods are called?
Maybe I miss an Intent flag on my startActivity
call?
Here is what I've figured out. If someone can tell me more accurate information about it I'll be happy to accept a "full" explaining answer.
Can someone explain how does Google achieve this behavior that only the
surfaceChanged
methods are called?
Answer: The surfaceChanged
method is called because the Interstitial Ad is displayed as full screen. I can trigger the same behavior following Googles description.
I strongly assume that the AdActivity
is not actually an activity (I'm happy if someone proofs me wrong) which is why surfaceDestroyed
and surfaceCreated
are not called when the Interstitial Ad is shown.