How avoid that the app be stopped or paused?


#1

Hello everybody,

I put in my code :

override fun onCreate(savedInstanceState: Bundle?)  {
    super.onCreate(savedInstanceState)

    val pm = this.getSystemService(Context.POWER_SERVICE) as PowerManager
    wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK or PowerManager.ON_AFTER_RELEASE, this.javaClass.name)

}

override fun onStart()
{
        super.onStart();
        if (wl != null) {
            wl!!.acquire();
        }
}

override fun onDestroy()
{
    super.onDestroy();
     if (wl != null) {
            wl!!.release();
        }
}

but It does not work, my app is stopped as soon as I run it.
Do you have an idea ?

thank you