0 down vote favorite
I have started a JNI application from MainActivity, which then calls updateStatus method of MainActivity:
private fun updateStatus(appContext: Context, event: String) {
this@MainActivity.runOnUiThread {
setContentView(R.layout.activity_main)
layout = findViewById(R.id.mainActivityLayout) as RelativeLayout
...
}
}
The problem is that setContentView call crashes the application:
03-21 08:41:01.185 1606 1606 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
The same call works fine when I call it in the beginning of MainActivity.
I have started a JNI application from MainActivity, which then calls updateStatus method of MainActivity:
private fun updateStatus(appContext: Context, event: String) {
this@MainActivity.runOnUiThread {
setContentView(R.layout.activity_main)
layout = findViewById(R.id.mainActivityLayout) as RelativeLayout
...
}
}
The problem is that setContentView call crashes the application:
03-21 08:41:01.185 1606 1606 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
The same call works fine when I call it in the beginning of MainActivity.