javaandroidwebviewjava-native-interfacenative-activity

How to create classes exclusively in JNI / Android Native Acitivites


I have Web Views working in my Native Activity, without any java at all. Because I'm writing a NativeActivity, using Java is quite painful (if not impossible). And it's not too hard to get WebView's working. But one issue is the WebViews can only do things like navigate to URLs, or kind of execute JavaScript.

But any kind of callback functionality is difficult -- unless -- there is some way using the JNI only, to create a new ValueCallback<String>, in C which would override the onReceiveValue function. Only issue is I can't seem to find any examples of this.

What is the general approach to "generating" classes in the JNI / Native Activities


Solution

  • It appears it is impossible to generate the classes without actual Java code.

    The solution for me was to use WebMessage Pipes and intercept null callbacks. See this:

    Acessing MessagePayloadJni class in JNI