I get the error"java.lang.IllegalStateException: Must be called from main thread" when using the "recreate()" function to refresh my activity in Kotlin-Android Studio.
What is causing the error?
Edit: I solved the problem by running the following instead: " runOnUiThread { recreate() } ", but I still do not understand why I get the error.