...
|
| ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
public class Database{ | CFxJavaString key( L"Id0" ); CFxStaticInvocation invocation( “com/domain/Database“ , “AddPair” “AddName” , “(Ljava/lang/String;Ljava/lang/String;)V” ); invocation.Call( true, key.GetJString() , value.GetJString() ); | ||||||||||
public class Database{ | jclass stringClass = GET_JAVA()->FindClass( "java/lang/String" ); CFxStaticInvocation invocation( “com/domain/Database“ , “SetNames” , “(Ljava/lang/String;)V” ); invocation.Call( true, names.GetJObject() ); |
...
|
| ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
public class Database{ | JNIEXPORT jstring JNICALL Java_com_domain_Database_GetName(1);( JNIEnv * env, jclass clazz, jint id ) | ||||||||||
public class Database{ String[] pair names = Database.GetPair(1);GetNames(); | JNIEXPORT jobjectarray JNICALL Java_com_domain_Database_GetNames( JNIEnv * env, jclass clazz ) |
Note: If an object is passed as return value back to Java, it is always necessary to use methods like GetStringJStringGetStrongJString() or GetStringJObjectGetStrongJObject() else there might runtime errors occur. These methods warrant the life time of an object even when the C++ method is being taken from call stack. For further samples look for any use of CFxStaticInvocation and CFxObjectInvocation in the SDK Android projects.