I defined a base class extends AsyncTask and have some custom method. I want to create some child classes which extend this, and override some methods. But by this way, its field will leaks the Context object.
abstract class ParentTask(context: Context) : AsyncTask<Void, Int, String>()
{
...
override fun doInBackground(vararg params: Void): String? {
...
}
...
}
Please tell me why and show me how to implement it in Android Kotlin? I'm very appreciated if there's an example about this. p/s : I'm searched for this but can't understand. Why using Singleton, or other design pattern
contextiscontext.applicationContextyou'll leak no activity.