I wrote this test application to try asynctask. it starts 5 background tasks and then has to reuse them. I just would like to know that everything is in order, since I could not find links to this problem. I would like to know why 5 tasks? Do they free up memory and all that they take? I would put this in a comment, but didn't seem to allow the code
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 { @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( ""); } }); }
and 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>
source share