blob: 0789b7e182f53b2a8930b4e806ade9a7bc304495 [file] [log] [blame]
Derek Sollenberger16ce3cd2009-09-01 16:27:31 -04001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17#include <string.h>
18#include <jni.h>
19#include <JNIHelp.h>
20#include <utils/Log.h>
21
22#define EXPORT __attribute__((visibility("default")))
23
24static jstring stringFromJNI( JNIEnv* env, jobject thiz )
25{
26 return env->NewStringUTF("Hello from JNI !");
27}
28
29/*
30 * JNI registration.
31 */
32static JNINativeMethod gJavaSamplePluginStubMethods[] = {
33 { "nativeStringFromJNI", "()Ljava/lang/String;", (void*) stringFromJNI },
34};
35
36EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
37
38 JNIEnv* env = NULL;
39
40 if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
41 return -1;
42 }
43
44 jniRegisterNativeMethods(env, "com/android/sampleplugin/SamplePluginStub",
45 gJavaSamplePluginStubMethods, NELEM(gJavaSamplePluginStubMethods));
46
47 return JNI_VERSION_1_4;
48}