I'm trying to refactor one of my activities. I have a very big private AsyncTask class, which I want to put in a separate class. The AsyncTask itself should also update the UI when finished, so I must provide the application context for that class.
Now which of those two is the better approach: Just create the class as a task?
public class MyCustomTask extends AsyncTask
Use with:
new MyCustomTask().execute();
Or create an Actitvity that itself launches the task, and call this Actitivy by Intent?
public class MyCustomActivity extends Activity {
onCreate() {
new MyCustomTask().execute();
}
private class MyCustomTask extends AsyncTask<..>();
}
Use with:
Intent intent = new Intent(this, MyCustomActivity.class);