Search code examples
androidkotlinandroidxkodein

Simple Kotlin Project does not show any UI


I have a very simple Android Project in Kotlin. Just to dig in Kodein. I can not see the two TextViews in the main_layout?

I have used MVP pattern for the only MainActivity I have there..

The app starts without a crash and is show a blank white screen.

Any hints?

BaseActivity:

abstract class BaseActivity<V : BasePresenter.View> : AppCompatActivity(), BasePresenter.View  {

    protected abstract val layoutResourceId : Int
    protected abstract val presenter : BasePresenter<V>

    val kodeinMu = LazyKodein(appKodein)

    protected abstract fun initUI()
    protected abstract fun initPresenter()

    override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
        super.onCreate(savedInstanceState, persistentState)
        setContentView(layoutResourceId)

        initUI()
        initPresenter()
    }

    override fun onPause() {
        super.onPause()
        presenter.pause()
    }

    override fun onStop() {
        super.onStop()
        presenter.stop()
    }

    override fun onDestroy() {
        super.onDestroy()
        presenter.destroy()
    }

    protected fun toast(s: String) {
        System.out.println("TAG $s")
    }
}

I have read that it is because of API 28 you only can see on API_28 devices or emulators. Either emulator or on real device were also blanked out.


Solution

  • You override the wrong onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) in you activity: use this : onCreate(savedInstanceState: Bundle?)