JNIpp: painless JNI C++ style

Quickly share your Android Code Snippets here...

JNIpp: painless JNI C++ style

Postby Dmitry.Skiba » Fri Jun 10, 2011 12:34 pm

Hello!

Allow me to introduce JNIpp library which uses the power of C++ to give you better Java native interface.
It features predefined wrappers for basic classes (Object, String, Class, etc.), wrappers for arrays (both primitive and object), exception translation between Java and C++, and finally, macros to simplify creation of your own wrapper classes.

Github project: https://github.com/DmitrySkiba/itoa-jnipp
Help and examples: http://dmitryskiba.github.com/itoa-jnipp/

As a demonstration I used JNIpp to get IMEI from native code: https://gist.github.com/1017293

Also there is a HelloJNIpp sample that shows how one can create wrappers for Activity, View and Canvas to implement completely native application with custom draw view.

Spoiler:
Code: Select all
void MainActivity::OnCreate(const jni::LObject& bundle) {
    Activity::OnCreate(bundle);
    SetContentView(R::GetLayout("main"));
    FindViewById(R::GetID("changeColor"))->
        SetOnClickListener(*this,&MainActivity::ChangeColor);
}
Dmitry.Skiba
Developer
Developer
 
Posts: 33
Joined: Thu Aug 28, 2008 12:52 pm

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 1 guest