0

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?

Community
  • 1
  • 1
fraiser
  • 929
  • 12
  • 28
  • 1
    Why would you need two? Volley makes http requests. It doesn't care that they'r'e two separate APIs. It doesn't even know that they are APIs- they could be images or webpages. – Gabe Sechan Apr 29 '17 at 21:47

1 Answers1

0

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.

Tangela
  • 161
  • 2
  • 13