android - How do I make my Volley response into a variable, so I can pass the value on to another activity using intents? -
i'm trying assign volley response variable, can pass value on activity using intents.
i'm wondering why thematchingcontacts string showing null in logcat. i'm seeing the matching contacts null
i have thematchingcontacts declared @ top of activity:
public class verifyuserphonenumber extends appcompatactivity { string thematchingcontacts; if user registered app, case, in oncreate :
else { getphonecontacts(); // start next activity intent myintent = new intent(verifyuserphonenumber.this, populistolistview.class); //we need phonenoofuser can user_id , corresponding //reviews in next activity myintent.putextra("keyname", phonenoofuser); myintent.putextra("jsonarraymatchingcontacts", thematchingcontacts); system.out.println("phonenoofuser" + phonenoofuser); system.out.println("the matching contacts " + thematchingcontacts); verifyuserphonenumber.this.startactivity(myintent); i'm seeing phonenoofuser alright, works. thematchingcontacts prints null. , function getphonecontacts() happens before intents part calls volley code below, getmatchingcontacts should initialized, right?
my volley code, further down, is:
stringrequest stringrequest = new stringrequest(request.method.post, checkphonenumber_url, new response.listener<string>() { @override public void onresponse(string response) { system.out.println(response); thematchingcontacts = response.tostring(); system.out.println(thematchingcontacts ); etc...etc... the response prints correctly. thematchingcontacts , in volley part of code. can't put intents code volley call activity needs other things before calling startactivity
you should execute code starts new activity in onresponse callback method of volley request, because, bob says, volley request asynchronous , want go next activity when request has finished.
Comments
Post a Comment