summaryrefslogtreecommitdiffstats
path: root/ndk
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-10-24 17:18:02 -0700
committerDianne Hackborn <hackbod@google.com>2010-10-25 17:01:49 -0700
commita77c1bdd4abf3c7e82af1f3b4330143d14c84103 (patch)
treee17066fc8732cf297d0a693cb51de6a4491a7907 /ndk
parent83c50ca740fabe25189601db90dc1f65ed4d2061 (diff)
downloadandroid_development-a77c1bdd4abf3c7e82af1f3b4330143d14c84103.tar.gz
android_development-a77c1bdd4abf3c7e82af1f3b4330143d14c84103.tar.bz2
android_development-a77c1bdd4abf3c7e82af1f3b4330143d14c84103.zip
Work on issue #3126018: No way to specify NativeActivity's native method
Update the header file to match the platform change. Also add an Android.mk so I can actually build this sample when I want to. Change-Id: I30c3c43fba7c233c59005d916888a46dc7049651
Diffstat (limited to 'ndk')
-rw-r--r--ndk/platforms/android-9/include/android/native_activity.h32
-rw-r--r--ndk/platforms/android-9/samples/native-activity/Android.mk70
-rw-r--r--ndk/platforms/android-9/samples/native-activity/jni/main.c2
3 files changed, 101 insertions, 3 deletions
diff --git a/ndk/platforms/android-9/include/android/native_activity.h b/ndk/platforms/android-9/include/android/native_activity.h
index a8f11c97e..d89bc8b9b 100644
--- a/ndk/platforms/android-9/include/android/native_activity.h
+++ b/ndk/platforms/android-9/include/android/native_activity.h
@@ -223,18 +223,34 @@ typedef void ANativeActivity_createFunc(ANativeActivity* activity,
/**
* The name of the function that NativeInstance looks for when launching its
- * native code.
+ * native code. This is the default function that is used, you can specify
+ * "android.app.func_name" string meta-data in your manifest to use a different
+ * function.
*/
extern ANativeActivity_createFunc ANativeActivity_onCreate;
/**
* Finish the given activity. Its finish() method will be called, causing it
- * to be stopped and destroyed.
+ * to be stopped and destroyed. Note that this method can be called from
+ * *any* thread; it will send a message to the main thread of the process
+ * where the Java finish call will take place.
*/
void ANativeActivity_finish(ANativeActivity* activity);
+/**
+ * Change the window format of the given activity. Calls getWindow().setFormat()
+ * of the given activity. Note that this method can be called from
+ * *any* thread; it will send a message to the main thread of the process
+ * where the Java finish call will take place.
+ */
void ANativeActivity_setWindowFormat(ANativeActivity* activity, int32_t format);
+/**
+ * Change the window flags of the given activity. Calls getWindow().setFlags()
+ * of the given activity. Note that this method can be called from
+ * *any* thread; it will send a message to the main thread of the process
+ * where the Java finish call will take place. See window.h for flag constants.
+ */
void ANativeActivity_setWindowFlags(ANativeActivity* activity,
uint32_t addFlags, uint32_t removeFlags);
@@ -247,6 +263,12 @@ enum {
ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002,
};
+/**
+ * Show the IME while in the given activity. Calls InputMethodManager.showSoftInput()
+ * for the given activity. Note that this method can be called from
+ * *any* thread; it will send a message to the main thread of the process
+ * where the Java finish call will take place.
+ */
void ANativeActivity_showSoftInput(ANativeActivity* activity, uint32_t flags);
/**
@@ -258,6 +280,12 @@ enum {
ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002,
};
+/**
+ * Hide the IME while in the given activity. Calls InputMethodManager.hideSoftInput()
+ * for the given activity. Note that this method can be called from
+ * *any* thread; it will send a message to the main thread of the process
+ * where the Java finish call will take place.
+ */
void ANativeActivity_hideSoftInput(ANativeActivity* activity, uint32_t flags);
#ifdef __cplusplus
diff --git a/ndk/platforms/android-9/samples/native-activity/Android.mk b/ndk/platforms/android-9/samples/native-activity/Android.mk
new file mode 100644
index 000000000..fa4543253
--- /dev/null
+++ b/ndk/platforms/android-9/samples/native-activity/Android.mk
@@ -0,0 +1,70 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+##################################################################
+#
+# NOTE: This is a helper to build this sample code using the
+# Android platform build system, inside of its source tree. This
+# is NOT part of the NDK and is not for use with the NDK build
+# system.
+#
+##################################################################
+
+# ----------------------------------------------------------------
+# Native code.
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := samples
+
+LOCAL_C_INCLUDES += \
+ $(TOPDIR)frameworks/base/native/include \
+ $(TOPDIR)frameworks/base/opengl/include \
+ $(TOPDIR)development/ndk/sources/android/native_app_glue
+
+LOCAL_SRC_FILES := \
+ jni/main.c jni/glutils.c \
+ ../../../../sources/android/native_app_glue/android_native_app_glue.c
+
+LOCAL_NDK_VERSION := 4
+LOCAL_SDK_VERSION := 8
+
+LOCAL_SHARED_LIBRARIES := liblog libandroid libEGL libGLESv1_CM
+
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_MODULE := libnative-activity
+
+include $(BUILD_SHARED_LIBRARY)
+
+# ----------------------------------------------------------------
+# Packaging .ap (and Java code if there was some)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := samples
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := NativeActivity
+
+LOCAL_CERTIFICATE := shared
+
+LOCAL_JNI_SHARED_LIBRARIES := libnative-activity
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/ndk/platforms/android-9/samples/native-activity/jni/main.c b/ndk/platforms/android-9/samples/native-activity/jni/main.c
index 9e95c205f..bdff031f6 100644
--- a/ndk/platforms/android-9/samples/native-activity/jni/main.c
+++ b/ndk/platforms/android-9/samples/native-activity/jni/main.c
@@ -119,7 +119,7 @@ static void engine_draw_frame(struct engine* engine) {
/**
* Tear down the EGL context currently associated with the display.
*/
-static int engine_term_display(struct engine* engine) {
+static void engine_term_display(struct engine* engine) {
if (engine->display != EGL_NO_DISPLAY) {
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (engine->context != EGL_NO_CONTEXT) {