Volley AppController class object returning null

前端 未结 4 1744
温柔的废话
温柔的废话 2021-01-19 12:46

I am making an app that makes a JsonObjectRequest and retrieves a JSON data from an URL using the Volley Networking Library for android.

AppCon

4条回答
  •  北海茫月
    2021-01-19 13:09

    you can't use an Activity like a Singleton. An Activity is a screen of your app and it could be in different states during the usage of your app. You are also leaking it, since you keep a static reference to it. For your purpose, if you need a Context, extend Application instead of AppCompatActivity, and register it in your Manifest.

提交回复
热议问题