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?

eyecreate
  • 1,017
  • 3
  • 14
  • 26

1 Answers1

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!

cody
  • 6,389
  • 15
  • 52
  • 77
  • so should I have the data type be "Integer[][]" instead? – eyecreate Dec 11 '10 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 Dec 11 '10 at 19:36
  • The pastebin I posted above shows that AsyncTask code. http://pastebin.ca/2016721 It does sometimes say something about xlint, maybe that's what xlint would tell me. – eyecreate Dec 11 '10 at 19:39
  • Ok. I made out an older post here about generics: http://stackoverflow.com/questions/2721546/why-dont-generics-support-primitive-types – cody Dec 11 '10 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. http://pastebin.ca/2016858 – eyecreate Dec 11 '10 at 21:41
  • I looked into it, but I didn't see any Integer Objects..? The int's definitely won't work ;) Did you instantiate and execute your AsyncTask? I saw you used it as an inner class. It would be useful to have a look at the whole code. – cody Dec 11 '10 at 22:00