JNI function calling to Facebook Android SDK

JNI function calling to Facebook Android SDK
0.0 0

#1

Hi, I m trying to call to Facebook android SDK methods through JNI…Here is my JNI Function where i m calling:

void InterfaceJNI::postMessageToFB()
{

JavaVM* jvm = JniHelper::getJavaVM();
int status;
JNIEnv *env;
jmethodID mid;

bool isAttached = false;

CCLog(“Static postMessageToFB”);

// Get Status
status = jvm~~>GetEnv &env, JNI_VERSION_1_4);

if
{
//LOGE;
status = jvm~~>AttachCurrentThread(&env, NULL);
CCLog(“Status 2: d", status);
if(status < 0)
{
// LOGE("callback_handler: failed to attach " // “current thread”);
return;
}
isAttached = true;
CCLog("Status isAttached: d”, isAttached);
}
//————————————————————

CCLog(“Status: d", status);

    jclass mClass = env-\>FindClass("org/mons/project/ShareOnFacebook");

    CCLog("jClass Located?");

    mid = env-\>GetMethodID(mClass, "postToWall", "(Ljava/lang/String;)V");
    jobject obj=env-\>NewGlobalRef(env-\>NewObject(mClass, mid));
    CCLog("mID: d”, mid);

if (mid!=0)
env~~>CallVoidMethod;
//————————————————————
CCLog;
if
jvm~~>DetachCurrentThread();

return;

}

But am getting errors…Here is my error log :

01-27 22:49:40.845: E/AndroidRuntime(719): FATAL EXCEPTION: GLThread 10
01-27 22:49:40.845: E/AndroidRuntime(719): java.lang.NullPointerException
01-27 22:49:40.845: E/AndroidRuntime(719): at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:100)
01-27 22:49:40.845: E/AndroidRuntime(719): at org.mons.project.ShareOnFacebook.showToast(ShareOnFacebook.java:143)
01-27 22:49:40.845: E/AndroidRuntime(719): at org.mons.project.ShareOnFacebook.postToWall(ShareOnFacebook.java:115)
01-27 22:49:40.845: E/AndroidRuntime(719): at org.cocos2dx.lib.Cocos2dxRenderer.nativeTouchesEnd(Native Method)
01-27 22:49:40.845: E/AndroidRuntime(719): at org.cocos2dx.lib.Cocos2dxRenderer.handleActionUp(Cocos2dxRenderer.java:120)
01-27 22:49:40.845: E/AndroidRuntime(719): at org.cocos2dx.lib.Cocos2dxGLSurfaceView$8.run(Cocos2dxGLSurfaceView.java:245)
01-27 22:49:40.845: E/AndroidRuntime(719): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1346)
01-27 22:49:40.845: E/AndroidRuntime(719): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1138)
01-27 22:49:40.850: I/GLThread(719): onPause tid=10
01-27 22:54:45.659: I/Process(719): Sending signal. PID: 719 SIG: 9

what am i doing wrong? i took a long time for searching my error but nothing works for me…Help me :slight_smile: