summaryrefslogtreecommitdiff
path: root/modules/gdnative/android/android_gdn.cpp
diff options
context:
space:
mode:
authorfhuya <fhuyakou@gmail.com>2019-05-30 12:50:36 -0700
committerfhuya <fhuyakou@gmail.com>2019-05-30 16:35:50 -0700
commit2c3536810a497165e063bd56f842c21cf38f22a5 (patch)
treeed4764bf467f4472aaee683f0e5b6058e96ce592 /modules/gdnative/android/android_gdn.cpp
parenta2cf1c3d049d0ca4de9d939550d1fb21c4d54297 (diff)
Setup Godot to support the Oculus Mobile SDK.
Diffstat (limited to 'modules/gdnative/android/android_gdn.cpp')
-rw-r--r--modules/gdnative/android/android_gdn.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/modules/gdnative/android/android_gdn.cpp b/modules/gdnative/android/android_gdn.cpp
index 8657935602..624ef19dec 100644
--- a/modules/gdnative/android/android_gdn.cpp
+++ b/modules/gdnative/android/android_gdn.cpp
@@ -34,6 +34,8 @@
// These entry points are only for the android platform and are simple stubs in all others.
#ifdef __ANDROID__
+#include "platform/android/java_godot_wrapper.h"
+#include "platform/android/os_android.h"
#include "platform/android/thread_jandroid.h"
#else
#define JNIEnv void
@@ -54,20 +56,31 @@ JNIEnv *GDAPI godot_android_get_env() {
jobject GDAPI godot_android_get_activity() {
#ifdef __ANDROID__
- JNIEnv *env = ThreadAndroid::get_env();
-
- jclass activityThread = env->FindClass("android/app/ActivityThread");
- jmethodID currentActivityThread = env->GetStaticMethodID(activityThread, "currentActivityThread", "()Landroid/app/ActivityThread;");
- jobject at = env->CallStaticObjectMethod(activityThread, currentActivityThread);
- jmethodID getApplication = env->GetMethodID(activityThread, "getApplication", "()Landroid/app/Application;");
- jobject context = env->CallObjectMethod(at, getApplication);
+ OS_Android *os_android = (OS_Android *)OS::get_singleton();
+ return os_android->get_godot_java()->get_activity();
+#else
+ return NULL;
+#endif
+}
- return env->NewGlobalRef(context);
+jobject GDAPI godot_android_get_surface() {
+#ifdef __ANDROID__
+ OS_Android *os_android = (OS_Android *)OS::get_singleton();
+ return os_android->get_godot_java()->get_surface();
#else
return NULL;
#endif
}
+bool GDAPI godot_android_is_activity_resumed() {
+#ifdef __ANDROID__
+ OS_Android *os_android = (OS_Android *)OS::get_singleton();
+ return os_android->get_godot_java()->is_activity_resumed();
+#else
+ return false;
+#endif
+}
+
#ifdef __cplusplus
}
#endif \ No newline at end of file