I read a lot about threads, handlers, loopers, etc., and I'm very confused. In my application, I want the first activity to start a background worker. This background worker will constantly request data from the TCP socket and (hopefully) put new information into the user interface stream as the data arrives. If the user moves on to a new action, the background should continue to do this, but only send different messages to the user interface stream so that it can update the new layout accordingly.
here is what i still have ... This is in my main activity file
public class MyTCPTest extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Handler handler = new Handler();
BgWorkerThread bgw = new BgWorkerThread();
bgw.start();
}
in another file, I define my workflow as this ...
public class BgWorkerThread extends Thread {
@Override
public void run(){
while(true)
{
try {
sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
, ? , , ? , , . ?
, , bgworker , , . ? BgWorkerThread, , Activity ?