I realize this issue is somewhat trivial, but I’m interested in knowing the “correct” answer.
I’m trying to extend android.os.AsyncTask,<Params, Progress, Result>
but my task doesn’t require any parameters.
Given that I have to overload protected Result doInBackground(Params... params),
what is the “best” way to pass in no parameters?
Currently, I’m using Object as the Params type and starting the task with:
new MyAsyncTask().execute( (Object)null );
This is totally functional, but I’m new to Java and don’t know if this is a good way of accomplishing what I’m trying to do.
Obviously I can’t put something like void or null in for the Params field, but if I use a wildcard I’m unsure of what to do about the arguments to doInBackground(Params... params).
Any suggestions?
Use
Void(note the capital V) for any data types that you do not need. Be sure to use the@Overrideannotation, so the compiler will catch any problems. Here is a sample application demonstrating this.