Skip to content Skip to sidebar Skip to footer

I Cannot Return A Linkedhashmap From Method And I Get Null

I use a method to get with volley my json object from server. The part that receives my object works fine, I get my response and I try to put my values into a linkedhashmap. When I

Solution 1:

When I try to return my map I get null. What I am doing wrong here?

You can't have your method return the map. Just make it void.

If you need to use the map, declare a method that accepts it as a parameter, pass the map through at the very end of onResponse within the Volley listener, and continue on with building an adapter and such within that new method.

That's how you are supposed to use asynchronous methods - in other words, you're getting null immediately returned while the Volley code is off in the background doing something else

Post a Comment for "I Cannot Return A Linkedhashmap From Method And I Get Null"