I want to create multiple handler and run-able when my app receive response from server.
The handlers can be maximum 4 and minimum 1.
Pr
If I correctly understand your code you need to replace
handler.postDelayed(myRunnable, 5000);
with
handler.postDelayed(this, 5000);
because myRunnable
is the latest Runnable that you created. And all your handlers post it instead of themselfs.
EDIT:
You store in each handler it's number - index
. You can add method
void handleResponse(int index, Object someData)
to your class, that creates handlers. After that each handler can call handleResponse(index, data)
to notify about some changes.