In my JNI project I need to add events/callbacks to the java client that will receive this event from the native library. In c++ I do it this way:
Dialog based:
SetProcessEventCallback((ProcessEvent) KSampleDlg::OnProcessEvent, this);
void KSampleDlg::OnProcessEvent(float fPercent, float fDeviceBuffer, float fCache, double dBytesWritten, double dImageSize, KSampleBurnDlg *pDlg)
{
pDlg->SetProgress((int)fPercent, (int)fCache);
}
In console app It works like
SetProcessEventCallback(OnProcess, 0);
void OnProcess(float fPercent, float fDeviceBuffer, float fCache,
double dBytesWritten, double dImageSize, void *pUserData)
{
static int nChars = 0;
g_cOutputLock.Lock();
while( (fPercent/100.0)*80 > nChars )
{
g_strBuffer += _T("*");
nChars++;
}
g_cOutputLock.UnLock();
}
After this event callback is set the library will fire this event to the given function. I can set the function and callback in the native lib but I have no idea how to fire this to the java app. Anyone can give me a hint how to handle this with JNI?