0

In many Android Studio projects, I should place additional code in override fun onDestroy() { } to release resources.

Should I place these codes before super.onDestroy() or after super.onDestroy() ?

In my mind, both the Code A and Code B I have met, which one is correct between Code A and Code B?

Code A

class ServiceRecord: Service() {

    private var job: Job? = null  

    override fun onDestroy() {       
        job?.cancel()
        super.onDestroy()
    }  
   
    ...
}

Code B

class ServiceRecord: Service() {

    private var job: Job? = null  

    override fun onDestroy() {              
        super.onDestroy()
        job?.cancel()
    }  
   
    ...
}
Mustafa Özçetin
  • 1,893
  • 1
  • 14
  • 16
HelloCW
  • 843
  • 22
  • 125
  • 310

0 Answers0