android volley can't get response -


i trying response instagram api using volley, can't data. did't receive call methods onresponse or onerrorresponse. nothing show up. not see error.

here code.

public string getuserid(string usrname) {     url = tcontants.urlbeforeuserid + usrname + tcontants.urlafteruser;      jsonobjectrequest jsonobjreq;     jsonobjreq = new jsonobjectrequest(method.get, url,             null, new response.listener<jsonobject>() {          @override         public void onresponse(jsonobject response) {             tagsresponse gsondata = gson.fromjson(response.tostring(), tagsresponse.class);             userid = gsondata.data[0].id.tostring();         }      }, new response.errorlistener() {         @override         public void onerrorresponse(volleyerror error) {             log.e("volley:", "getuserid response error");         }     });      appcontroller.getinstance().addtorequestqueue(jsonobjreq,             tcontants.tag_json_obj);     return userid; } 

url working fine, tested it.

when code running jsonobjectrequest creating. next step skip onresponse , onerrorresponse methods. plz help.

the code inside onresponse not skipped, that's how it's supposed work, looking @ callback.

a very quick , general explanation be:
code not run serially, instead, onresponse in case implementation of interface provided request object, called when response arrives, might take several milliseconds seconds (depending on server, since callback network operation).

read callback handling (both network, , simple ones create interfaces - , if haven't yet - read interfaces), major part of programming.

addition:

to see when response return, print parameters before sending them make sure sent correctly, , print response (response.tostring() @ beginning of onresponse) , wait bit see after request sent. (don't alarmed if print won't contain readable info, depends on implementation of .tostring() method, it's indication got response @ all).


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -