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
This commit is contained in:
Dianne Hackborn
2010-10-24 17:18:02 -07:00
parent 83c50ca740
commit a77c1bdd4a
3 changed files with 101 additions and 3 deletions

View File

@@ -223,18 +223,34 @@ typedef void ANativeActivity_createFunc(ANativeActivity* activity,
/** /**
* The name of the function that NativeInstance looks for when launching its * 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; extern ANativeActivity_createFunc ANativeActivity_onCreate;
/** /**
* Finish the given activity. Its finish() method will be called, causing it * 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); 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); 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, void ANativeActivity_setWindowFlags(ANativeActivity* activity,
uint32_t addFlags, uint32_t removeFlags); uint32_t addFlags, uint32_t removeFlags);
@@ -247,6 +263,12 @@ enum {
ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002, 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); void ANativeActivity_showSoftInput(ANativeActivity* activity, uint32_t flags);
/** /**
@@ -258,6 +280,12 @@ enum {
ANATIVEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002, 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); void ANativeActivity_hideSoftInput(ANativeActivity* activity, uint32_t flags);
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -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)

View File

@@ -119,7 +119,7 @@ static void engine_draw_frame(struct engine* engine) {
/** /**
* Tear down the EGL context currently associated with the display. * 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) { if (engine->display != EGL_NO_DISPLAY) {
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (engine->context != EGL_NO_CONTEXT) { if (engine->context != EGL_NO_CONTEXT) {