0

I can use AsyncTask as an inner class to get the returned result then assign it to the global String var.

But now my idea is to use the AsyncTask like this. My caller method and MyAsyncTask class are different classes:

    //in my caller class
    String returned_string = new MyAsyncTask().execute(myparams); //The MyAsyncTask class returns the string after it's done everything.
    Log.v("RETURNED STRING",returned_string); //Check if the returned string is correct

But of course it cannot be done because they are in different type.

I don't know if my idea is possible?

Thank you for your time.

Tran Hoai Nam
  • 1,273
  • 2
  • 18
  • 35
  • 1
    Possible duplicate of [Android: pass function reference to AsyncTask](http://stackoverflow.com/questions/26202568/android-pass-function-reference-to-asynctask) – OneCricketeer Jun 09 '16 at 15:03
  • 1
    Assigning global variables outside the scope of an AsyncTask is not preferred. While possible, the better approach is a callback. – OneCricketeer Jun 09 '16 at 15:03

0 Answers0