androidweb-servicesandroid-asynctaskmatrixcursor

how to get data back from onPostExecute


I have a class which is implementing FilterQueryProvider and having an inner class which is extending AsyncTask. I am using this inner class to call a REST API and getting data successfully in onPostExecute which is MatrixCursor. But I want this MatrixCursor data in runQuery() method of outer class.

I am calling REST API in onCreate method. How can I get it in runQuery method???


Solution

  • Declare matrixcursor in the Activity class, initiate it on onCreate and use the same in the inner class. you can then access and modify if from inner async task and access it from activity class.
    Ex.

    mAsyncTask.execute(....);
    mAsyncTask.get();
    runQuery();