is it in general better to create AsyncTask as private class within an Activitiy, or rather separate them in an own class?
public class MyActivity extends Activity {
private class DownloadPage extends AsyncTask {
}
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
AsyncTask inside Activity is more suitable after completing backgroud task you can change view easily.
In seperate class you need to pass
contextand its result comes in seperate class and then you have to get result from seperate class.But seperate class is very useful sometimes when we need more asyncTask in application ,
and if you have large code in your activity so its better to use seperate class.
So AsyncTask is suitable inside Activity to interact with view…and seperate class is also
suitable when we need more asynctask in application.
So its totally depends on requirements…