Opposite of “ANativeWindow\_fromSurface”

Issue

With the method

ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface);

I can get ANativeWindow object.

Can I get the opposite? [jobject of surface from ANativeWindow]

(I want to use this surface in java…)

Solution

Since Android API level 26, there is

jobject ANativeWindow_toSurface(JNIEnv *env, ANativeWindow *window)

Return a Java Surface object derived from the ANativeWindow, for interacting with it through Java code.

https://developer.android.com/ndk/reference/group/native-activity#anativewindow_tosurface

Answered By – Neat

Leave a Comment