I have exactly the same problem. My solution uses proxy textures . This means that when you create textures using some data from memory or a file, you create a dummy texture containing a copy of the memory data or the path to the file (you can preload the data into memory for faster loading).
After that, the next time my handler calls bind () (something like glBindTexture), I check if there is data to load, and if it exists, I just create a new texture and load the data.
This approach suits me better, because in my case, textures can be created from any stream and at any time.
But if you want to preload all the textures, you can just do it in onSurfaceCreated or onSurfaceChanged
The same goes for buffers.
Another approach is to use your own activity (check out the NDK example). In this case, you can process the context manually, but it requires API level 9.
source share