Answer the question
In order to leave comments, you need to log in
How to pass data to AsyncTask Android?
Hello, I'm trying to send a message to AsyncTask, which stores the Bitmap. But for some reason null comes in AsyncTask. Please tell me what I'm doing wrong. Thanks in advance.
private synchronized void runRecognition(Message message){
new RecognizeAsyncTack().execute(message);
}
private final class RecognizeAsyncTack extends AsyncTask<Message, Void, OcrDB>{
@Override
protected void onPreExecute() {
super.onPreExecute();
isRecognizing = true;
}
@Override
protected OcrDB doInBackground(Message... params) {
Message message = params[0];
return decodeByteMessage((Bitmap) message.obj, message.arg1, message.arg2);
}
@Override
protected void onPostExecute(OcrDB result) {
super.onPostExecute(result);
activity.setOcrResult(result);
isRecognizing = false;
}
}
Answer the question
In order to leave comments, you need to log in
I solved the problem by replacing the object of type Message with my own class. Apparently something with Handler'om. Thanks
I tried debugging or logging, maybe you are losing it somewhere, so it comes as null?
Stuff checks and output to the logs, before each use, if you haven’t done so.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question