i new android. using sockets in asynchronous task , wish pass data activity called it. not want asynchronous task handle ui. wish pass data. class e![enter image description here][1]xtends async task not part of class extends activity
my activity has 2 buttons. when button clicked, async task called , corresponding changes should made rest of activity.
from how send data onpostexecute in asynctask:
class youractivity extends activity { private static final int dialog_loading = 1; public void oncreate(bundle savedstate) { setcontentview(r.layout.yourlayout); new longrunningtask1().execute(1,2,3); } private void onbackgroundtaskdataobtained(list<string> results) { //do stuff results here.. } private class longrunningtask extends asynctask<long, integer, list<string>> { @override protected void onpreexecute() { //do pre execute stuff } @override protected list<string> doinbackground(long... params) { list<string> mydata = new arraylist<string>(); (int = 0; < params.length; i++) { try { thread.sleep(params[i] * 1000); mydata.add("some data" + i); } catch(interruptedexception ex) { } } return mydata; } @override protected void onpostexecute(list<string> result) { youractivity.this.onbackgroundtaskdataobtained(result); } } }
Comments
Post a Comment