I wrote this test app to try the asynctask. it runs 5 background tasks, and then must reuse them. I would just like to know that this is OK as I have not been able to find any reference to this concern. I would like to know why 5 tasks? Do they release memory and whatever else they are taking? I would have put this in a comment but didnt seem to allow code snips
package com.mvw.tas;
import java.io.IOException;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class TestAsync extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btnD = (Button)findViewById(R.id.Btn01);
btnD.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
new gback().execute( "");
}
});
}
////////////////////////////////////////
public class gback extends AsyncTask<String, Void, IOException> {
//@Override
protected IOException doInBackground(String... params) {
Log.d( "ASTEST", "Running background");
return null;
}
@Override
protected void onPostExecute(IOException result) {
Log.d( "ASTEST", "Post Exec");
}
@Override
protected void onPreExecute() {
Log.d( "ASTEST", "PRE Exec");;
}
}
}
and the XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button android:text="Test AysncTask" android:id="@+id/Btn01" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>