Skip to content

Commit 8e177cd

Browse files
committedFeb 27, 2012
bringing in hellojni to wrap the leveldb android setup
1 parent 3eadd70 commit 8e177cd

File tree

8 files changed

+224
-0
lines changed

8 files changed

+224
-0
lines changed
 

‎.gitignore

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# private constants #
2+
NonPublicConstants.java
3+
4+
.externalToolBuilders
5+
.cproject
6+
.project
7+
.settings
8+
.classpath
9+
project.properties
10+
11+
bin
12+
gen
13+
obj
14+
libs
15+
16+
# Compiled source #
17+
###################
18+
target
19+
*.com
20+
*.class
21+
*.dll
22+
*.exe
23+
#*.o
24+
#*.so
25+
26+
# Packages #
27+
############
28+
# it's better to unpack these files and commit the raw source
29+
# git has its own built in compression methods
30+
*.7z
31+
*.dmg
32+
*.gz
33+
*.iso
34+
*.jar
35+
*.rar
36+
*.tar
37+
*.zip
38+
39+
# Logs and databases #
40+
######################
41+
#*.log
42+
#*.sql
43+
#*.sqlite
44+
45+
# OS generated files #
46+
######################
47+
.DS_Store
48+
ehthumbs.db
49+
Icon?
50+
Thumbs.db
51+
52+
lint.xml
53+

‎AndroidManifest.xml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.hellojni"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="11"/>
7+
<application android:label="@string/app_name"
8+
android:debuggable="true">
9+
<activity android:name=".HelloJni"
10+
android:label="@string/app_name">
11+
<intent-filter>
12+
<action android:name="android.intent.action.MAIN" />
13+
<category android:name="android.intent.category.LAUNCHER" />
14+
</intent-filter>
15+
</activity>
16+
</application>
17+
</manifest>

‎jni/leveldb_sample.c

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
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+
20+
/* This is a trivial JNI example where we use a native method
21+
* to return a new VM String. See the corresponding Java source
22+
* file located at:
23+
*
24+
* apps/samples/hello-jni/project/src/com/example/HelloJni/HelloJni.java
25+
*/
26+
jstring
27+
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
28+
jobject thiz )
29+
{
30+
return (*env)->NewStringUTF(env, "Hello from JNI !");
31+
}

‎res/values/strings.xml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="app_name">HelloJni</string>
4+
</resources>
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
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+
package com.example.hellojni;
17+
18+
import android.app.Activity;
19+
import android.widget.TextView;
20+
import android.os.Bundle;
21+
22+
23+
public class HelloJni extends Activity
24+
{
25+
/** Called when the activity is first created. */
26+
@Override
27+
public void onCreate(Bundle savedInstanceState)
28+
{
29+
super.onCreate(savedInstanceState);
30+
31+
/* Create a TextView and set its content.
32+
* the text is retrieved by calling a native
33+
* function.
34+
*/
35+
TextView tv = new TextView(this);
36+
tv.setText( stringFromJNI() );
37+
setContentView(tv);
38+
}
39+
40+
/* A native method that is implemented by the
41+
* 'hello-jni' native library, which is packaged
42+
* with this application.
43+
*/
44+
public native String stringFromJNI();
45+
46+
/* This is another native method declaration that is *not*
47+
* implemented by 'hello-jni'. This is simply to show that
48+
* you can declare as many native methods in your Java code
49+
* as you want, their implementation is searched in the
50+
* currently loaded native libraries only the first time
51+
* you call them.
52+
*
53+
* Trying to call this function will result in a
54+
* java.lang.UnsatisfiedLinkError exception !
55+
*/
56+
public native String unimplementedStringFromJNI();
57+
58+
/* this is used to load the 'hello-jni' library on application
59+
* startup. The library has already been unpacked into
60+
* /data/data/com.example.HelloJni/lib/libhello-jni.so at
61+
* installation time by the package manager.
62+
*/
63+
static {
64+
System.loadLibrary("leveldb");
65+
}
66+
}

‎tests/AndroidManifest.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
3+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
4+
package="com.example.HelloJni.tests"
5+
android:versionCode="1"
6+
android:versionName="1.0">
7+
<!-- We add an application tag here just so that we can indicate that
8+
this package needs to link against the android.test library,
9+
which is needed when building test cases. -->
10+
<application>
11+
<uses-library android:name="android.test.runner" />
12+
</application>
13+
<!--
14+
This declares that this application uses the instrumentation test runner targeting
15+
the package of com.example.HelloJni. To run the tests use the command:
16+
"adb shell am instrument -w com.example.HelloJni.tests/android.test.InstrumentationTestRunner"
17+
-->
18+
<instrumentation android:name="android.test.InstrumentationTestRunner"
19+
android:targetPackage="com.example.HelloJni"
20+
android:label="Tests for HelloJni"/>
21+
</manifest>

‎tests/default.properties

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system use,
7+
# "build.properties", and override values to adapt the script to your
8+
# project structure.
9+
10+
# Project target.
11+
target=android-3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.example.HelloJni;
2+
3+
import android.test.ActivityInstrumentationTestCase;
4+
5+
/**
6+
* This is a simple framework for a test of an Application. See
7+
* {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
8+
* how to write and extend Application tests.
9+
* <p/>
10+
* To run this test, you can type:
11+
* adb shell am instrument -w \
12+
* -e class com.example.HelloJni.HelloJniTest \
13+
* com.example.HelloJni.tests/android.test.InstrumentationTestRunner
14+
*/
15+
public class HelloJniTest extends ActivityInstrumentationTestCase<HelloJni> {
16+
17+
public HelloJniTest() {
18+
super("com.example.HelloJni", HelloJni.class);
19+
}
20+
21+
}

0 commit comments

Comments
 (0)
Please sign in to comment.