titanae
titanae

Reputation: 2289

Adding Java WebView to pure Android NDK application

I have a pure NDK application, entirely C++.

I now need to add access to a WebView; Google search and stack-overflow have informed me that I have to do this in Java.

How do I go about including Java class (derived from WebView) into my pure Android NDK application and how do I invoke it?

Note: I am not using Eclipse or any other IDE, just .mk file etc.

Upvotes: 1

Views: 1544

Answers (1)

Jake
Jake

Reputation: 690

You would have to use JNI and make an upcall from your C++-code to Java. Calling a Java language method from within native code involves the following three steps:

  1. Retrieve a class reference
  2. Retrieve a method identifier
  3. Call the methods

There's a good explaination on how to do this here: Sun JNI Reference

You need a Java class that can receive this method call, and that can start up an Activity containing a webview. So, you can include and invoke Java from C++, but naturally you still need to implement the Java-class in Java, there's no getting away from that.

Upvotes: 2

Related Questions