CAndroidVMHelper.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifdef VCMI_ANDROID
  12. #include <jni.h>
  13. #include <string>
  14. /// helper class that allows access to java vm to communicate with java code from native
  15. class CAndroidVMHelper
  16. {
  17. JNIEnv * envPtr;
  18. bool detachInDestructor;
  19. jclass findClass(const std::string & name, bool classloaded);
  20. public:
  21. CAndroidVMHelper();
  22. ~CAndroidVMHelper();
  23. JNIEnv * get();
  24. jclass findClassloadedClass(const std::string & name);
  25. void callStaticVoidMethod(const std::string & cls, const std::string & method, bool classloaded = false);
  26. std::string callStaticStringMethod(const std::string & cls, const std::string & method, bool classloaded = false);
  27. static void cacheVM(JNIEnv * env);
  28. static void cacheVM(JavaVM * vm);
  29. static constexpr const char * NATIVE_METHODS_DEFAULT_CLASS = "eu/vcmi/vcmi/NativeMethods";
  30. };
  31. #endif