CAndroidVMHelper.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * CAndroidVMHelper.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include <jni.h>
  12. #include <string>
  13. /// helper class that allows access to java vm to communicate with java code from native
  14. class CAndroidVMHelper
  15. {
  16. JNIEnv * envPtr;
  17. bool detachInDestructor;
  18. jclass findClass(const std::string & name, bool classloaded);
  19. public:
  20. CAndroidVMHelper();
  21. ~CAndroidVMHelper();
  22. JNIEnv * get();
  23. jclass findClassloadedClass(const std::string & name);
  24. void callStaticVoidMethod(const std::string & cls, const std::string & method, bool classloaded = false);
  25. std::string callStaticStringMethod(const std::string & cls, const std::string & method, bool classloaded = false);
  26. static void cacheVM(JNIEnv * env);
  27. static void cacheVM(JavaVM * vm);
  28. static constexpr const char * NATIVE_METHODS_DEFAULT_CLASS = "eu/vcmi/vcmi/NativeMethods";
  29. };