WebView from NDK to Android

Is there a way to open a WebView from android ndk ? We can call the java method from the jni C ++ file, and we can open the web view, but we need to open the web view directly from android ndk without java interference.

+4
source share
1 answer

You cannot access the Java UI from the NDK code. NDK got the basic functionality to draw material on the screen, suitable for writing games, but what is it.

If you want to use WebView, you will have to embed it in the Java user interface and then access it through the JNI. I can no longer comment on further details about what you are trying to do, but the usual use cases:

  • the game wants to launch the URL: the game is invoked in Java through the JNI, and the Java side launches it as an intent.

  • the game wants to view some HTML in the user interface: the game is called in Java via the JNI, and on the Java side, Activity is launched with a web interface.

There are also many ways to cheat, for example. having user activity without a title, and a transparent background with a WebView on it appears on top of your NativeActivity. It all depends on what you want to do, but it will all be related to JNI.

+1
source

Source: https://habr.com/ru/post/1395410/


All Articles