Skip to content

Instantly share code, notes, and snippets.

@avram
Last active December 25, 2015 17:39
Show Gist options
  • Save avram/7014243 to your computer and use it in GitHub Desktop.
Save avram/7014243 to your computer and use it in GitHub Desktop.
class MyActivity extends Activity {
private Thread myWorker = new Thread() {
public void run() {
URL url = new URL("http://reddit.com/story");
url.openConnection();
String body = url.getBody();
myView.post(new Runnable() { public void run() {myView.setText(body)} });
}
}
private TextView myView;
public void onCreate(..) {
myView = (TextView) findViewById(..);
myWorker.start();
}
public interface OnStory {
public void onStory(String story);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment