android - Can i make Json Volley request in main thread? -


i need make json request , set ui depending on response, nice make in in oncreate in same thread.

speaking requestfuture, can't rely use this, or dont know how.

requestfuture<jsonobject> future = requestfuture.newfuture(); jsonobjectrequest request = new jsonobjectrequest(url, null, future, future); requestqueue.add(request);  try {   jsonobject response = future.get();   count = response.getin("int"); } catch (interruptedexception e) { } catch (executionexception e) { }catch (jsonexception e) {             toast.maketext(getactivity(), e.tostring(), toast.length_long).show();         } 

i tried this, dont work.

if know pls show example how data jsonobject , dont nothing befor data goten , use values set views.

as there getactivity() in code, bet in fragment. on ui thread call this

    getactivity().runonuithread(new runnable() {         @override         public void run() {             // ui-related code goes here             }     }); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -