What I want it's to pass one int
variable to my AsyncTask
.
int position = 5;
And I declared my AsyncTask like this:
class proveAsync extends AsyncTask<int, Integer, Void> {
protected void onPreExecute(){
}
protected Void doInBackground(int... position) {
}
.
.
.
But I got an error that it's the following:
Type argument cannot be of primitive type
I just could pass an int[]
and Integer
variables but never an int
variable and I execute my AsyncTask
like this:
new proveAsync().execute(position);
Is there something that I could do to pass only this position
?
Thanks in advance!
Pass your parameter as Integer
class proveAsync extends AsyncTask<Integer, Integer, Void> {
protected void onPreExecute(){
}
protected Void doInBackground(Integer... position) {
int post = position[0].intValue();
}
.
.
.
while executing do this
new proveAsync().execute(new Integer(position));
You can get the int value in AsyncTask
as using intValue()
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