hello
i need to pass 2 strings from android activity to C native code in JNI folder
from android activity i use :
String uno = "prima";
String due = "prova";
String a = stringFromJNI(uno, due);
from C code in JNI folder i have this function :
#include <string.h>
#include <jni.h>
/* This is a trivial JNI example where we use a native method
* to return a new VM String. See the corresponding Java source
* file located at:
*
* apps/samples/hello-jni/project/src/com/example/hellojni/HelloJni.java
*/
jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject thiz, jstring a, jstring b )
{
char s[100];
const char *aa = (*env)->GetStringUTFChars(env, a, 0);
const char *bb = (*env)->GetStringUTFChars(env, b, 0);
strcat(s, aa);
strcat(s, bb);
return (*env)->NewStringUTF(env, s);
}
compile function is ok ,
the execution give me this message :
08-29
16:57:10.229: W/dalvikvm(13846): JNI WARNING: input is not valid
Modified UTF-8: illegal continuation byte 0x70
08-29 16:57:10.229:
W/dalvikvm(13846): string: ',#�primaprova'
08-29
16:57:10.229: W/dalvikvm(13846): in com/example/hellojni/HelloJni;.stringFromJNI:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
(NewStringUTF)
08-29 16:57:10.229: I/dalvikvm(13846): "main"
prio=5 tid=1 NATIVE
08-29 16:57:10.229: I/dalvikvm(13846): |
group="main" sCount=0 dsCount=0 obj=0x409e8460
self=0x12800
08-29 16:57:10.229: I/dalvikvm(13846): |
sysTid=13846 nice=0 sched=0/0 cgrp=[fopen-error:2]
handle=1075102856
08-29 16:57:10.229: I/dalvikvm(13846): |
schedstat=( 308264887 107238356 282 ) utm=29 stm=1 core=0
why ?
tanks for help
william