Showing an Android PopupWindow over a NativeActivity

860 views Asked by At

I'm trying to implement AdMob in my Android game which has been ported using the NDK, and SDL. I've been following the example here, but when I call showAdPopup, my game's Activity seems to be destroyed, I'm left with a blank grey screen, with an ad at the bottom. The logs seem to show my activity being paused when the popup window is shown.

I've commented out all of the admob code and it seems that the problem is reproducible just by trying to create a PopupWindow over my NativeActivity. I noticed there is a sample app here which has almost identical code to mine, but that sample has disappeared from the SDK in later versions (I'm targeting android-19).

Does anyone know why my native activity seems to pause/shutdown when I try to launch a popupwindow? Did something change in android-19 that stops this approach from working?

1

There are 1 answers

0
Kazade On BEST ANSWER

Turns out that by calling:

_activity.setContentView(mainLayout, params);

I was destroying the SDL context. The solution is to use the existing layout that SDL's activity creates and add the popup window to that.