0
I have a class that looks for a list of clients in the background with a AsyncTask
. She can be called any Activity
, and returns nothing, just looks for the list of customers that comes in json
and saves that list as string
in a SharedPreferences
.
Initially, I’m sending to search the list on my login screen, so when I bring the user data from the database, it already sends to search the client list (to reduce the data search wait), but I needed when this class saved the list on SharedPreferences
my Activity
which opens after the login is notified so I fill a RecyclerView
with her. I thought of Implementing a Interface
in AsyncTask
but she returns to the Activity
who called her.
Do you have any method to notify Activity
even if the function was not started by it?
Note: If you do not understand the question, comment before negative that I will be happy to clarify your doubts.
Yes it is possible, but this approach may fail if the list is saved before the activation of the activty. In that case the Activity does not receive the notification.
– ramaral
Is there any other way?
– Bruno Romualdo
The normal is the data to be read by the Activity that uses them or be passed on to her.
– ramaral
I’ve done it but sometimes it takes too long and I need the search to be quick.
– Bruno Romualdo
If you want to try, even though you know you can fail, look at this reply.
– ramaral
I’ll take a look.
– Bruno Romualdo