java - Issue with Parse: outstanding network connection. -
i have encountered outstanding network connection error while trying run application. have attach logcat below see messages getting.
essentially, trying populate page display various information parse database user such name, age, , profile picture.
08-18 15:14:58.973: e/androidruntime(11753): fatal exception: main 08-18 15:14:58.973: e/androidruntime(11753): process: com.dooba.beta, pid: 11753 08-18 15:14:58.973: e/androidruntime(11753): java.lang.runtimeexception: query has outstanding network connection. have wait until it's done. 08-18 15:14:58.973: e/androidruntime(11753): @ com.parse.parsequery.checkifrunning(parsequery.java:204) 08-18 15:14:58.973: e/androidruntime(11753): @ com.parse.parsequery.findinbackground(parsequery.java:629) 08-18 15:14:58.973: e/androidruntime(11753): @ com.dooba.beta.fragment1.setconversationslist(fragment1.java:148) 08-18 15:14:58.973: e/androidruntime(11753): @ com.dooba.beta.fragment1.onactivitycreated(fragment1.java:71) 08-18 15:14:58.973: e/androidruntime(11753): @ android.support.v4.app.fragment.performactivitycreated(fragment.java:1508) 08-18 15:14:58.973: e/androidruntime(11753): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:958) 08-18 15:14:58.973: e/androidruntime(11753): @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1115) 08-18 15:14:58.973: e/androidruntime(11753): @ android.support.v4.app.backstackrecord.run(backstackrecord.java:682) 08-18 15:14:58.973: e/androidruntime(11753): @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1478) 08-18 15:14:58.973: e/androidruntime(11753): @ android.support.v4.app.fragmentmanagerimpl.executependingtransactions(fragmentmanager.java:478) 08-18 15:14:58.973: e/androidruntime(11753): @ android.support.v4.app.fragmentpageradapter.finishupdate(fragmentpageradapter.java:141) 08-18 15:14:58.973: e/androidruntime(11753): @ android.support.v4.view.viewpager.populate(viewpager.java:1068) 08-18 15:14:58.973: e/androidruntime(11753): @ android.support.v4.view.viewpager.populate(viewpager.java:914) 08-18 15:14:58.973: e/androidruntime(11753): @ android.support.v4.view.viewpager.onmeasure(viewpager.java:1436) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.view.measure(view.java:16497) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5125) 08-18 15:14:58.973: e/androidruntime(11753): @ android.widget.linearlayout.measurechildbeforelayout(linearlayout.java:1404) 08-18 15:14:58.973: e/androidruntime(11753): @ android.widget.linearlayout.measurevertical(linearlayout.java:695) 08-18 15:14:58.973: e/androidruntime(11753): @ android.widget.linearlayout.onmeasure(linearlayout.java:588) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.view.measure(view.java:16497) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5125) 08-18 15:14:58.973: e/androidruntime(11753): @ android.widget.framelayout.onmeasure(framelayout.java:310) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.view.measure(view.java:16497) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5125) 08-18 15:14:58.973: e/androidruntime(11753): @ android.widget.linearlayout.measurechildbeforelayout(linearlayout.java:1404) 08-18 15:14:58.973: e/androidruntime(11753): @ android.widget.linearlayout.measurevertical(linearlayout.java:695) 08-18 15:14:58.973: e/androidruntime(11753): @ android.widget.linearlayout.onmeasure(linearlayout.java:588) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.view.measure(view.java:16497) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:5125) 08-18 15:14:58.973: e/androidruntime(11753): @ android.widget.framelayout.onmeasure(framelayout.java:310) 08-18 15:14:58.973: e/androidruntime(11753): @ com.android.internal.policy.impl.phonewindow$decorview.onmeasure(phonewindow.java:2291) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.view.measure(view.java:16497) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.viewrootimpl.performmeasure(viewrootimpl.java:1916) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.viewrootimpl.measurehierarchy(viewrootimpl.java:1113) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1295) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1000) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:5670) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.choreographer$callbackrecord.run(choreographer.java:761) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.choreographer.docallbacks(choreographer.java:574) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.choreographer.doframe(choreographer.java:544) 08-18 15:14:58.973: e/androidruntime(11753): @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:747) 08-18 15:14:58.973: e/androidruntime(11753): @ android.os.handler.handlecallback(handler.java:733) 08-18 15:14:58.973: e/androidruntime(11753): @ android.os.handler.dispatchmessage(handler.java:95) 08-18 15:14:58.973: e/androidruntime(11753): @ android.os.looper.loop(looper.java:136) 08-18 15:14:58.973: e/androidruntime(11753): @ android.app.activitythread.main(activitythread.java:5017) 08-18 15:14:58.973: e/androidruntime(11753): @ java.lang.reflect.method.invokenative(native method) 08-18 15:14:58.973: e/androidruntime(11753): @ java.lang.reflect.method.invoke(method.java:515) 08-18 15:14:58.973: e/androidruntime(11753): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 08-18 15:14:58.973: e/androidruntime(11753): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 08-18 15:14:58.973: e/androidruntime(11753): @ dalvik.system.nativestart.main(native method) 08-18 15:15:06.893: i/process(11753): sending signal. pid: 11753 sig: 9
below complete code
public class fragment1 extends fragment { public interface constants { string log = "com.dooba.beta"; } private string currentuserid; private arrayadapter<string> namesarrayadapter; private arraylist<string> names; private arraylist<string> age; private arraylist<string> headline; private arraylist<string> activityname; private arraylist<images> alprofilepicture; private listview userslistview; private button logoutbutton; string usergender = parseuser.getcurrentuser().getstring("gender"); string activityname = parseuser.getcurrentuser().getstring("activityname"); number maxdistance = parseuser.getcurrentuser().getnumber( "maximum_distance"); string userlookinggender = parseuser.getcurrentuser().getstring( "looking_gender"); number minimumage = parseuser.getcurrentuser().getnumber("minimum_age"); number maximumage = parseuser.getcurrentuser().getnumber("maximum_age"); number userage = parseuser.getcurrentuser().getnumber("age"); @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); setconversationslist(); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment1_layout, container, false); return view; } private void setconversationslist() { currentuserid = parseuser.getcurrentuser().getobjectid(); names = new arraylist<string>(); age = new arraylist<string>(); headline = new arraylist<string>(); activityname = new arraylist<string>(); alprofilepicture = new arraylist<images>(); // string useractivityselectionname = null; parsequery<parseuser> query = parseuser.getquery(); // query.whereequalto("activityname",useractivityselectionname); query.wherenotequalto("objectid", parseuser.getcurrentuser() .getobjectid()); // users gender = currentuser.looking_gender query.whereequalto("gender", userlookinggender); // users looking_gender = currentuser.gender query.whereequalto("looking_gender", usergender); query.setlimit(1); query.whereequalto("activityname", activityname); // query.wheregreaterthanorequalto("age", minimumage); // query.wherelessthanorequalto("age", maximumage); query.orderbydescending("name"); log.d(constants.log, ""); query.findinbackground(new findcallback<parseuser>() { @override public void done(list<parseuser> objects,parseexception e) { for(int i=0;i<objects.size();i++){ // whatever need extract object "users" parsequery<parseobject> query = parsequery.getquery("user"); parsefile image = objects.get(i).getparsefile("profilepicture"); parseimageview imageview = (parseimageview) getview().findviewbyid(r.id.profilepictureresult); // placeholder used before , during fetch, replaced fetched image // data. imageview.setplaceholder(getresources().getdrawable(r.drawable.profile_pict)); imageview.setparsefile(image); imageview.loadinbackground(new getdatacallback() { @override public void done(byte[] data, parseexception e) { log.i("parseimageview", "fetched! data length: " + data.length + ", or exception: " + e.getmessage()); } }); } }//for loop }); query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> userlistname, parseexception e) { if (e == null) { (int = 0; < userlistname.size(); i++) { names.add(userlistname.get(i).get("name").tostring()); } userslistview = (listview) getactivity().findviewbyid( r.id.userlistname); namesarrayadapter = new arrayadapter<string>(getactivity() .getapplicationcontext(), r.layout.user_list_item, names); userslistview.setadapter(namesarrayadapter); userslistview .setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long) .show(); } } }); query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> userlistheadline, parseexception e) { if (e == null) { (int = 0; < userlistheadline.size(); i++) { headline.add(userlistheadline.get(i).get("headline") .tostring()); } userslistview = (listview) getactivity().findviewbyid( r.id.userlistheadline); namesarrayadapter = new arrayadapter<string>(getactivity() .getapplicationcontext(), r.layout.user_list_all, headline); userslistview.setadapter(namesarrayadapter); userslistview .setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long) .show(); } } }); } public void openconversation(arraylist<string> names, int pos) { parsequery<parseuser> query = parseuser.getquery(); query.whereequalto("name", names.get(pos)); query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> user, parseexception e) { if (e == null) { intent intent = new intent(getactivity() .getapplicationcontext(), messagingactivity.class); intent.putextra("recipient_id", user.get(0).getobjectid()); startactivity(intent); } else { toast.maketext(getactivity().getapplicationcontext(), "error finding user", toast.length_short) .show(); } } }); } }
any assistance appreciated, incredibly stuck on this. in advance , if need clarification, let me know.
java.lang.runtimeexception: query has outstanding network connection. have wait until it's done.
it sounds parsequery
doesn't support multiple concurrent find requests.setconversationslist()
reuses same query instance execute 3 background requests. since aren't changing query each of requests, can handle in single findcallback
.
note: breaking method sub-methods make code easier read , debug.
edit:
every handler starts on list argument , calls get()
on each object, different argument.
for (int = 0; < users.size(); i++) { //... users.get(i).get("xxxx") //... }
i expect able call get()
each of different arguments within single call back. once collect information, can update ui.
for (parseuser user : users) { //... user.get("aaa") user.get("bbb") user.get("ccc") //... }
you can use for-each loop instead of calling users.get(i)
every time.
Comments
Post a Comment