Unsupportedoperationexception While Calling Volley Request With Headers
I try to make call request with Volley library. I want to set headers, but I'm getting java.lang.UnsupportedOperationException. Do you know why , and how can I solve this problem ?
Solution 1:
Remove these two lines:
Map<String,String> params = super.getHeaders();
if(params==null)params = newHashMap<>();
And add just this:
Map<String, String> params = newHashMap<>();
It should work now.
Solution 2:
Use the below method to solve UnsupportedOperationException
:
overridefungetHeaders(): MutableMap<String, String> {
val header = HashMap<String, String>()
// header[Constants.AUTH_TOKEN] = Constants.TOKEN_IDreturn header
}
This is working for me.
Post a Comment for "Unsupportedoperationexception While Calling Volley Request With Headers"