Qt android calling from java to C++

From java to C++

First define a native function declaration inside java code.


public static native void setAction(int arg);
[\sourcecode]

This can be used for invoke function connection from java code in the form:


setAction(1234);
[\sourcecode]

This is all from java side since all the job is made from C++ side.


extern “C”
{

JNIEXPORT void JNICALL Java_com_cnx_eyerismain_MyCustomAppService_setAction(JNIEnv env, jobject obj, jint action)
{
qDebug()<<"****** eyeris_main onReceiveAction"<<action;
// call MainWindow::onReceiveMounted from Qt thread

qDebug()<<"can tell here that message is received "<<action;
globalIsNewAction = true;
globalCurrentAction = action;
}

}
[\sourcecode]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s