Android Forums

Go Back   These FORUMS ARE DISABLED!! OUR NEW FORUMS ARE AT http://androidforum.com/ > Android Coders > Android Development, Answers, Tutorials, and Code Snippets
Connect with Facebook

Click Here To Register!
 
 
LinkBack Thread Tools Display Modes
Old 08-02-2010, 12:24 AM   #1
New Member
 
Join Date: Aug 2010
Posts: 2
Friends: 0
View dappersoul12's Profile   View dappersoul12's Photo Album   View dappersoul12's Blog   View Social Groups
i have an object that is used for calling callback functions ----- static jobject o;

i have assigned the callback function to that object through a pointer, env -----

o=env->NewGlobalRef(callback);

The same pointer, env, points towards the function CallVoidMethod( ) that uses JNI to reach to the java code.

env->CallVoidMethod(o, methodId, pDeviceId, deviceStatus, statusReason, connectionProgressInfo);

However on calling this function, the system is getting crashed, and VM says that it's an invalid reference to static jobject o and then it crashes.

My code is as follows :

static jint android_net_wimax_subscribeDeviceStatusChange(JNIE nv* env, jobject clazz, jobject jdeviceId, jobject callback)
{

// LOGD(" android_net_wimax_subscribeDeviceStatusChange() ->D1");
o = env->NewGlobalRef(callback);
//o = callback;

// LOGD(" android_net_wimax_subscribeDeviceStatusChange() ->D2");


return (jint)::SubscribeDeviceStatusChange(deviceId, fun_IndDeviceStatusUpdate);
}

void fun_IndDeviceStatusUpdate(WIMAX_API_DEVICE_ID_P pDeviceId, WIMAX_API_DEVICE_STATUS deviceStatus,
WIMAX_API_STATUS_REASON statusReason, WIMAX_API_CONNECTION_PROGRESS_INFO connectionProgressInfo)
{

JNIEnv *env = NULL;
int nResult = -1;


// LOGD(" AttachCurrentThread() ->D1");

nResult = g_jVM->AttachCurrentThread(&env, NULL);

// LOGD(" AttachCurrentThread() ->D2-%d",nResult);

if ((nResult != 0) || (env == NULL))
{
LOGD(" AttachCurrentThread() failed");
}
else
{
// LOGD(" AttachCurrentThread() ->D3");


if(deviceStatusChangeCB == NULL)
{

LOGD(" deviceStatusChangeCB is NULL ");

}
else
{
LOGD(" deviceStatusChangeCB is not NULL ");

}

jclass cls = env->GetObjectClass(deviceStatusChangeCB);

// LOGD(" AttachCurrentThread() ->D4");
jmethodID methodId = env->GetMethodID(cls, "callback", "(Landroid/net/wimax/structs/DeviceId;III)V");

// LOGD(" AttachCurrentThread() failed->D5");
if (methodId) {
env->CallVoidMethod(o, methodId, pDeviceId, deviceStatus, statusReason, connectionProgressInfo);
}

if (g_jVM->DetachCurrentThread() != JNI_OK) {
LOGE("%s: DetachCurrentThread() failed", __FUNCTION__);
}
}

// LOGD("JNI->CALLBACK->D3");

}


Kindly help me out
dappersoul12 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
 

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can anyone help me out in getting a good android reference book?? nikhilgupta Android Hardware 2 08-30-2010 12:13 PM
Can't send text message - "invalid content" rangephil Hero 3 01-05-2010 02:02 PM


Unlocked G1 Phones | Buy T-Mobile G1 | Google Phone

All times are GMT -6. The time now is 08:30 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright (c) 2012 TalkAndroid.com. All rights reserved.