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+ */
116package com .androidmontreal .opencv ;
217
318import android .app .Activity ;
19+ import android .widget .TextView ;
420import android .os .Bundle ;
521
6- public class AndroidOpenCVforHackathonsActivity extends Activity {
22+
23+ public class AndroidOpenCVforHackathonsActivity extends Activity
24+ {
725 /** Called when the activity is first created. */
826 @ Override
9- public void onCreate (Bundle savedInstanceState ) {
27+ public void onCreate (Bundle savedInstanceState )
28+ {
1029 super .onCreate (savedInstanceState );
30+
31+ /* Create a TextView and set its content.
32+ * the text is retrieved by calling a native
33+ * function.
34+ */
1135 setContentView (R .layout .main );
36+ TextView tv = (TextView ) findViewById (R .id .textview1 );
37+ tv .setText ( stringFromJNI () );
38+
39+ }
40+
41+ /* A native method that is implemented by the
42+ * 'hello-jni' native library, which is packaged
43+ * with this application.
44+ */
45+ public native String stringFromJNI ();
46+
47+ /* This is another native method declaration that is *not*
48+ * implemented by 'hello-jni'. This is simply to show that
49+ * you can declare as many native methods in your Java code
50+ * as you want, their implementation is searched in the
51+ * currently loaded native libraries only the first time
52+ * you call them.
53+ *
54+ * Trying to call this function will result in a
55+ * java.lang.UnsatisfiedLinkError exception !
56+ */
57+ public native String unimplementedStringFromJNI ();
58+
59+ /* this is used to load the 'hello-jni' library on application
60+ * startup. The library has already been unpacked into
61+ * /data/data/com.example.HelloJni/lib/libhello-jni.so at
62+ * installation time by the package manager.
63+ */
64+ static {
65+ System .loadLibrary ("hello-jni" );
1266 }
13- }
67+ }
0 commit comments