title: Getting Valid JNIEnv pointer
body: <p>I have a C++ dll that I want to use in Unity by exporting the functions to C#. The Unity project runs on Android devices and the C++ code makes use of java. To initialize the C++ I need to call the following function first: </p>
  
  <pre><code>void api_initialize(JNIEnv* env, jobject* app_context, jobject* class_loader) {
  
      JavaVM* vm = nullptr;
      env-&gt;GetJavaVM(&amp;vm);
      if (!vm) {
        return;
      }
  
      //Do other proprietary things
  }
  </code></pre>
  
  <p>In Unity I have the following exported Dll function </p>
  
  <pre><code>    [DllImport (dllName)]
      private static extern void api_initialize (IntPtr java_env, IntPtr app_context, IntPtr class_loader);
  </code></pre>
  
  <p>My question is <strong>How do I get a JNIEnv pointer in my C# class to then pass as a parameter into this function?</strong></p>
  
  <p>I am not the creator of this API and don't have the access to modify it, so I need to get the JavaVM from the JNIEnv, not the other way around. </p>