Android/Java: how to delay return in a method

后端 未结 3 1853
抹茶落季
抹茶落季 2020-11-30 15:02

I want to build a Utils class to make Volley calls simpler, like this:

Utils.java:

public class Utils {
static JsonObjectRequest mJsonObjectRequest;          


        
3条回答
  •  借酒劲吻你
    2020-11-30 15:14

    If you execute makeJsonObjectRequest on a background thread, then you can execute synchronous Volley request this way: Can I do a synchronous request with volley?

    If you execute makeJsonObjectRequest on the UI thread, then you shouldn't wait for onResponse to avoid blocking UI thread. Use callback in this case.

提交回复
热议问题