Hi Siva,
your printf call will be executed in C, while I presume you would like
to see something being done in Java :)
If you just want to see your method is being called, you have 2
options:
a. in JNIEXPORT void JNICALL Java_com_android_Test_show(JNIEnv *env,
jobject obj)
open a file and write something dummy in it. You will be able to see
this file on the disk, after you call it.

b. return something in java from your function, for example your
function could look like:
static JNIEXPORT jstring JNICALL
libVer (JNIEnv *env, jclass cls)
{
   MLOG("function started\n");
   return env->NewStringUTF("Lib ver 1.0");
}

In this example you return a string containing the lib version.

For a whole tutorial consult the NDK (in there you have 2 examples).
For more complicated examples check our post here:
http://www.itwizard.ro/category/android-cc

Best regards,
ITWiz


On Sep 10, 10:39 am, Peli <peli0...@googlemail.com> wrote:
> You were posting to the wrong forum.
>
> Post your question here to get help:http://groups.google.com/group/android-ndk
>
> Peliwww.openintents.org
>
> On Sep 10, 8:17 am, pink 444 <pnk...@gmail.com> wrote:
>
> > Hai,
> >     I am newbie to Android ,Hence can you explain it in detail .
>
> > Thanks in Advance,
> > -Siva.
>
> > On Sep 10, 11:02 am, Dianne Hackborn <hack...@android.com> wrote:
>
> > > Hi, you are more likely to get help on android-ndk.
>
> > > On Wed, Sep 9, 2009 at 9:36 PM, pink 444 <pnk...@gmail.com> wrote:
>
> > > > hai folks,
>
> > > >            In Android , Native code is written as follows.
>
> > > > JNIEXPORT void JNICALL Java_com_android_Test_show(JNIEnv *env, jobject
> > > > obj)
> > > > {
> > > >      printf("THIS IS TEST");
> > > > }
>
> > > > JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
> > > > {
> > > >        JNIEnv *env;
> > > >        JNINativeMethod meth;
> > > >        jclass k;
> > > >        jint r;
>
> > > >        r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4);
> > > >        k = (*env)->FindClass (env, "com.android.Test.show");
>
> > > >        meth.name = "show";
> > > >        meth.signature = "()V";
> > > >        meth.fnPtr = Java_com.android.Test.show;
> > > >        r = (*env)->RegisterNatives (env, k, &meth, 1);
> > > >        return JNI_VERSION_1_4;
>
> > > > }
>
> > > > JNIEXPORT void JNI_OnUnload(JavaVM *vm, void *reserved)
> > > > {
> > > >        JNIEnv *env;
> > > >        jclass k;
> > > >        jint r;
> > > >        r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4);
> > > >        k = (*env)->FindClass (env, "com.android.Test.show");
> > > >        (*env)->UnregisterNatives(env, k);
>
> > > > }
>
> > > > While executing on Android the following messages are obeserved in adb
> > > > logcat.
>
> > > > JNI     (  524): Trying to load jni .so
> > > > I/System.out(  524): /system/lib
> > > > D/dalvikvm(  524): Trying to load lib /data/libjnilibs.so 0x433f22d0
> > > > D/dalvikvm(  524): Added shared lib /data/libjnilibs.so 0x433f22d0
> > > > I/ActivityManager(   50): Displayed activity
> > > > com.android.helloactivity
>
> > > > But "THIS IS TEST" is not being displayed, which is displayed in
> > > > native code.
>
> > > > There are no errors regarding loading shared library and calling
> > > > native code.Then why is the message is not displayed in logging.
>
> > > > Am i doing any mistake.If JNI_OnLoad and JNI_OnUnLoad are not
> > > > implemented i am getting errors in Logging.If i do as above i not
> > > > getting that native code message.
>
> > > > Any help would be appreciated highly.
>
> > > > Regards,
> > > > -Siva.
>
> > > --
> > > Dianne Hackborn
> > > Android framework engineer
> > > hack...@android.com
>
> > > Note: please don't send private questions to me, as I don't have time to
> > > provide private support, and so won't reply to such e-mails.  All such
> > > questions should be posted on public forums, where I and others can see 
> > > and
> > > answer them.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to