Issue
for my app I made a framework for all network calls to an external API. I put everything in "Services" like: UserService
, MessageService
etc. So now when I want to call a network method I can't do this in the UI-Thread of my Activity
so I made an AsyncTask
and everything was just fine =)
But now I want something like giving the method to execute to the AsyncTask
so I don't need to write an AsyncTask
for every method of my network-framework. So instead of having something like this:
public class NetworkTask extends AsyncTask<UserService, Void, Void> {
@Override
protected Void doInBackground(UserService... params) {
UserService userService = params[0];
userService.getUser();
return null;
}
}
I want something more "abstract" so the AsyncTask
doesn't need to know the "getUser" method? But I can't find any idea of how to do this... Maybe the AsyncTask is not good for this anyway?
Solution
There are plenty AsyncTask alternatives :
and plus Needle - Multithreading library for Android
Answered By - WebComer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.