i'm trying to send a line of text from java to c and then have it send back to c to be displayed in a textview.
Why does my windows keep closing when i run this code?
c++ code
extern "C"
JNIEXPORT jstring JNICALL
Java_com_example_tony_c_MainActivity_getStrLen(JNIEnv *env, jobject instance, jstring filename) {
const char *javastring = env->GetStringUTFChars(filename , NULL ) ;
env->ReleaseStringUTFChars(filename, javastring);
return env->NewStringUTF(javastring);
}
java code
public class MainActivity extends AppCompatActivity {
// Used to load the 'native-lib' library on application startup.
static {
System.loadLibrary("native-lib");
}
// private int getStrLen;
// private Object s;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Example of a call to a native method
TextView tv = findViewById(R.id.sample_text);
tStrLen());
getStrLen("hello shit this works");
}
public native int getStrLen(String javastring);
public native String getStrLen();
}
Maybe it requires some sort of "pause" function? It's a common thing especially when you're using Visual Studio with the debugging on.
how do i pause it, im using android studio.
its not the pause as soon as it hits this line " this.getStrLen() " in the textview it shutdown.
Last edited on