16

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

Prashant Kadam
  • 1,207
  • 4
  • 18
  • 30
  • 1
    Why you want to pass null? If you don't want the Integer value as a parameter to AsyncTask? – Lalit Poptani May 21 '12 at 05:08
  • 1
    reduce the number of references to an object by assigning null. if object is no longer referenced so it will be available for the garbage collection i.e. the compiler will destroy it and the free memory will be allocated to the other object. – Prashant Kadam May 21 '12 at 05:33
  • see this also http://stackoverflow.com/questions/36325277/why-does-system-out-printlnnull-give-the-method-printlnchar-is-ambiguo – Kannan Thangadurai Apr 12 '16 at 06:03

1 Answers1

19

This should work:

new AsynPageLoader().execute((Integer) null);
  • 1
    thanks RC. its work fine with integer but what about Void data type Ex> class UpdataColumnTask extends AsyncTask { @Override protected Void doInBackground(Void... params) { return null; } } – Prashant Kadam May 21 '12 at 05:14
  • 1
    is there other way to reduce the number of references to an object by assigning null – Prashant Kadam May 21 '12 at 05:34