unable to pass null to execute(); method of AsyncT

2019-04-04 03:12发布

问题:

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

回答1:

This should work:

new AsynPageLoader().execute((Integer) null);