i created an AsyncTask as shown below in the code so that the value to be published through onPublishProgress is of type double, but at run time i receive the below posted logCat errors
please help me to find the reason why i am getting this error
Code:
this.mbtnShowComp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mATComputations = new mATComputations();
mATComputations.execute();
}
});
private class mATComputations extends AsyncTask <Void, Double, Void> {
private int mI = 0;
private double mResult;
@Override
protected Void doInBackground(Void... params) {
Log.w(TAG, CSubTag.msg("mATComputations.doInBackground"));
while (!isCancelled()) {
this.mResult += (((++this.mI)/10) * (50));
publishProgress(this.mResult);
}
return null;
}
@Override
protected void onProgressUpdate(Double... values) {
super.onProgressUpdate(values);
Log.w(TAG, CSubTag.msg("mATComputations.onProgressUpdate"));
mtvComputations.setText(""+(values[0]));
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
Log.w(TAG, CSubTag.msg("mATComputations.onPostExecute"));
}
@Override
protected void onCancelled() {
super.onCancelled();
Log.w(TAG, CSubTag.msg("mATComputations.onCancelled"));
}
}
logcat
FATAL EXCEPTION: AsyncTask #2
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: Process: com.example.com.bt_11, PID: 953
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: java.lang.RuntimeException: An error occured while executing doInBackground()
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at android.os.AsyncTask$3.done(AsyncTask.java:300)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:242)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at java.lang.Thread.run(Thread.java:818)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: Caused by: java.lang.ClassCastException: java.lang.Object[] cannot be cast to java.lang.Void[]
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at com.example.com.bt_11.ActConnect2$mATComputations.doInBackground(ActConnect2.java:1902)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:288)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
01-14 10:59:47.220 953-1958/com.example.com.bt_11 E/AndroidRuntime: at java.lang.Thread.run(Thread.java:818)