0

I have a app I'm making with an AsyncTask. The result of the task needs to be assigned to a variable in the base app class. I currently have:

    protected void onPostExecute(int[][]... end) {
        MainVar=end[0];
    }

but this doesn't transfer the data. I'm guessing I'm going about this wrong, but I wasn't sure how to do it reading the docs, so how should this be done?

2

1 Answer 1

1

It's generally right what you tried. You're given the result of the type int[][] in onPostExecute(). But don't use primitive types. AsyncTask Extensions are generic and need three types: AsyncTask<Params, Progress, Result> which may be Void or anything else (but no primitive data type). Hope that helps!

6
  • so should I have the data type be "Integer[][]" instead?
    – eyecreate
    Commented Dec 11, 2010 at 19:16
  • Yes, you could use that. But I wonder how you implemented your AsyncTask with int[][] , as the java compiler already should have complained because generics don't accept primitive types...
    – cody
    Commented Dec 11, 2010 at 19:36
  • The pastebin I posted above shows that AsyncTask code. pastebin.ca/2016721 It does sometimes say something about xlint, maybe that's what xlint would tell me.
    – eyecreate
    Commented Dec 11, 2010 at 19:39
  • Ok. I made out an older post here about generics: stackoverflow.com/questions/2721546/…
    – cody
    Commented Dec 11, 2010 at 19:41
  • After converting the int to Integer, I still have the data not being transferred. Here is an updated pastebin of the other var in case it helps. pastebin.ca/2016858
    – eyecreate
    Commented Dec 11, 2010 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.