Hi all,
I'm trying to resolve a problem I have where a native activity will display a black frame for a short period when I add a ViewGroup to a native activity via addContentView(View, LayoutParams) from Java. This only seems to happen the very first time the addContentView function is called - the ViewGroup can be removed from it's parent view group and then re-added via the same addContentView call without the same effect occurring again.
From investigations the black frame seems to be that the window/surface gets destroyed when
the view hierarchy changes hence the native activity isn't
able to draw anything. Eventually the terminate window and init window
commands come through and the native activity re-creates it's display. This makes sense as I expect a period of time for the commands to come through to the native thread, however I would have thought the black frame issue would present itself each time I called addContentView() but it doesn't so does anyone know why this only happens the first time I call
addContentView()?
Also, I've tried a few things to try and workaround the issue but so far not found a good solution. Is it possible to stop the surface from being destroyed when adding the
new ViewGroup in the first place? If not are there any suggestions as to alternative methods for adding the ViewGroup to the view hierarchy in way that avoids this problem?
As a bit of background and/or in case it's of use, the native activity in this instance is an edited basic OpenGL native activity sample from the (r9c) NDK that I am using for testing purposes and the ViewGroup I am adding from Java is a small hierarchy consisting a ViewGroup and child GLSurfaceView. This is part of a library project that overlays an OpenGL view on top of the activity and generally works fine with standard Java applications and NDK projects that do now use the native_app_glue code but seems to have a few issues when used via a native activity using the native_app_glue module.
Any ideas or solutions greatly appreciated! :)
Thanks,
Duane