How to close Android application in Kotlin

前端 未结 2 854
执念已碎
执念已碎 2021-01-13 10:56

In JAVA we can close the application. We trying to develop skills with Kotlin and feel we are using the correct syntax to close the application. The issue is that the code o

2条回答
  •  时光说笑
    2021-01-13 11:39

    Grendel here is the absolute easiest two ways to close the Kotlin App the first way will open the app on PageTwo when it is reloaded not elegant but I included on the chance that someone has a Splash Screen

         moveTaskToBack(true);
         exitProcess(-1)
    

    The second way is so simple and old you are going to scream It will close the Kotlin App and when reloaded the MainActivity is shown first

    finishAffinity()
    

    I tested this with Nexus 9 API 26 I do not have a Samsung Galaxy S2 but feel free to mail me one ha ha

提交回复
热议问题