/**
* Return the ANativeWindow associated with a Java Surface object,
* for interacting with it through native code. This acquires a reference
* on the ANativeWindow that is returned; be sure to use ANativeWindow_release()
* when done with it so that it doesn't leak.
*/
ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface);
jobject surfaceLocalRef = ...
ANativeWindow* nativeWindow = ANativeWindow_fromSurface( env, surfaceLocalRef );
env->DeleteLocalRef( surfaceLocalRef );
// keep using nativeWindow until you call ANativeWindow_release( )