Skip to content

Instantly share code, notes, and snippets.

@douyw
Created November 12, 2012 00:24
Show Gist options
  • Save douyw/4056908 to your computer and use it in GitHub Desktop.
Save douyw/4056908 to your computer and use it in GitHub Desktop.
android jni support
#ifdef OS_ANDROID
#include <android/log.h>
/*#include <string.h>*/
#include <jni.h>
#define LOG_TAG "libexample"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
#endif // OS_ANDROID
#ifdef OS_ANDROID
jint
Java_com_example_MainActivity_start( JNIEnv* jnienv,
jobject thiz, jstring path )
{
const char *cpath = (*jnienv)->GetStringUTFChars(jnienv, path, NULL), PATH_MAX);
// TODO: free cpath
// (*jnienv)->FreeUTFChars
return 0; // return port if ok, otherwise 0
}
jint
Java_com_example_MainActivity_stop( JNIEnv* jnienv,
jobject thiz )
{
return 0;
}
#endif // OS_ANDROID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment