Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to pass null to execute(); method of AsyncTask in android 4.0

Tags:

People also ask

What can I use instead of AsyncTask in Android?

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.

In which thread AsyncTask function will execute?

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 .

What are the problems in AsyncTask?

In summary, the three most common issues with AsyncTask are: Memory leaks. Cancellation of background work. Computational cost.

What is the use of AsyncTask in Android?

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