Skip to content

Instantly share code, notes, and snippets.

@avram avram/gist:7014243
Last active Dec 25, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.