Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经阅读了 Volley 的一些积木。所有人都要求将 RequestQueue 用作 SingleTon。
为什么它应该是单例的?
为什么我们不能随时创建 RequestQueue?
Volley 旨在对您的所有请求进行排队。拥有多个队列是没有意义的,这就是为什么它是单例的。
您可以在项目的任何地方使用定义RequestQueue的public static并class使用它:
RequestQueue
public static
class
public static RequestQueue requestQueue = Volley.newRequestQueue(getActivity());