0
我想在函數PrintLog()中使用類成員「tvLog」,它將在C++的JNI中調用。但它導致了「關閉虛擬機....致命異常:主....」錯誤。有誰能告訴我爲什麼?JNI回調函數可以使用類成員嗎?
simple_test.java:
public class simple_test extends Activity {
private TextView tvLog = (TextView)findViewById(R.id.LogTextView);
public int PrintLog(int i) {
tvLog.setText("Log from JNI");
return 0;
}
}
demo_jni.cpp
...
mid = env->GetMethodID(cls, "PrintLog", "(I)I");
...
int ret = env->CallIntMethod(obj, mid, 1);
...
main.xml中:
<TextView android:text="" android:layout_x="14dp" android:layout_y="147dp" android:layout_width="290dp" android:layout_height="98dp" android:id="@+id/LogTextView"></TextView>
完全堆棧TRA ce,會有幫助。 – SplinterReality
你如何獲得cls對象? – njzk2