Alternative 1: Using Executor and Handler The executor will help in performing any task in the background and the handler will help to make UI changes.
An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread. An asynchronous task is defined by 3 generic types, called Params , Progress and Result , and 4 steps, called onPreExecute , doInBackground , onProgressUpdate and onPostExecute .
In summary, the three most common issues with AsyncTask are: Memory leaks. Cancellation of background work. Computational cost.
Android AsyncTask is an abstract class provided by Android which gives us the liberty to perform heavy tasks in the background and keep the UI thread light thus making the application more responsive. Android application runs on a single thread when launched.
i am trying to pass null value to execute(); method of AsyncTask in android 4.0 it show error "The method execute(Integer[]) is ambiguous for the type" but same code is work fine with android 2.2 Code is :
public class AllianceAnalysisDemoActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
new AsynPageLoader().execute(null);
}
public class AsynPageLoader extends AsyncTask<Integer, Integer, Bitmap> {
@Override
protected void onPreExecute() {
// progressBar.setVisibility(VISIBLE);
}
@Override
protected Bitmap doInBackground(Integer... params) {
return null;
}
@Override
protected void onPostExecute(Bitmap result) {
if (result != null && result.getHeight() > 0
&& result.getWidth() > 0) {
}else {
}
}
}
}
please help me how to pass null value .execute(null); method in android 4.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With