Reputation: 969
I'm using two API's in my Android app. I was creating a Singleton
class as described in https://developer.android.com/training/volley/requestqueue.html and the first answer of Android Volley - How to isolate requests in another class.
However, since I'm using two different APIs, should I create two instances of the NetworkManager
or Singleton
class, after making all the variables in this class not static? Or can I just use the same instance to handle all types of requests?
Upvotes: 0
Views: 363
Reputation: 161
I would recommend each activity/fragment has it's own RequestQueue. If the activity needs to make request out to different api's you should still use the same RequestQueue. Each different api request should have it owns StringRequest and then add them to the RequestQueue.
So you would create a NetworkManager for each RequestQueue you would be making but you only need one instance for each activity/fragment.
Upvotes: 0