To Amit :
To interaction between C and Java maybe a little complicate, you can do it
follows this:
*"Because each class loader maintains a set of native libraries, the
programmer may use a single library to store all the native methods needed
by any number of classes as long as those classes have the same defining
loader. *
*Native libraries will automatically be unloaded by the virtual machine when
their corresponding class loaders are garbage collected."*
it a example
JNIEXPORT jstring JNICALL Java_Prompt_getLine
(JNIEnv *env, jobject obj, jstring prompt)
{
char buf[128];
const char *str = (*env)->GetStringUTFChars(env, prompt, 0);
printf("%s", str);
(*env)->ReleaseStringUTFChars(env, prompt, str);
}
I just writed a document about this, but sorry it is a Chinese version, i
will post it after tranlate to English
2008/12/2 Amit <[EMAIL PROTECTED]>
>
> Android supports JNI at application framework level.
> For example, in platform/frameworks/base.git, Mediaplayer.java at:
>
> http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=media/java/android/media/MediaPlayer.java;h=b6064e1bb6b0f40f72fc1535b264f5c3fa190548;hb=HEAD
> file has got some native function calls
> And these native function calls must be implemented in either
> libmedia_jni.so or media_jni.dll
> but i'm unable to located either of the files in the source code. plz
> tell me the path if they are present in the source code.
>
> i found a c++ file android_media_MediaPlayer.cpp at:
>
> http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=media/jni/android_media_MediaPlayer.cpp;h=f9f3646f0c308bf19bb3c3af02fc0e0e4260afbd;hb=HEAD
> that implements the corresponding native functions,
> but coudnt find how it calls the actual c/c++ libraries. Also, it
> includes files media/mediaplayer.h which i coudnt find.
> This must be the file generated by java file using javah.
>
> It also included files JNIHelp.h and android_runtime/AndroidRuntime.h
> which are also untraceable.
> Plz help me in this problem.
>
> Thanks
> Amit
>
> On Dec 1, 2:07 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
> > Hi Amit,
> >
> > DigitalAirways (www.digitalairways.com) does this to allow all the
> > Kaleido applications to run on Android with great performances and
> > very limited porting effort.
> >
> > Franck
> >
> > On Nov 28, 11:00 am, Amit <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > Hello friends,
> >
> > > Can u plz tell that if i want to write some piece of code for android
> > > in c or c++, how can i integrate the code with java code.
> >
> > > Any help appreciated
> >
> > > Thanks
> > > Amit- Hide quoted text -
> >
> > - Show quoted text -
> >
>
--
Best Regards
Eric Chan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---