NullPointerException addToRequestQueue(com.android.volley.Request, java.lang.String)' on a null object reference

后端 未结 7 1617
你的背包
你的背包 2020-12-09 08:32

I\'m using AndroidHive register login and it\'s working fine in example project of this login-register.

But after many attempts trying it with CardViews

7条回答
  •  鱼传尺愫
    2020-12-09 09:22

    In my case, I forgot to initialize the variable rq, please, make sure you did it

        ...
        private RequestQueue rq;   // rq = null (NullPointerException if you use it)
        ...
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            ...
            rq = Volley.newRequestQueue(YourActivity.this);  // rq != null
        }
        ...
        rq.add(request);
    

提交回复
热议问题