0

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???

1 Answer 1

0

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(); 
Sign up to request clarification or add additional context in comments.

3 Comments

But problem is that when i use it in runQuery its showing count 0.Means data is getting loaded after method call.
Use yourAsyncTask.get(); to get the result. This will wait for doInbackground() to complete. You can then run runQuery
can i pass matrixcursor in place of cursor as argument in a method?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.