import android.widget.*; import android.view.*; import android.content.Context; import android.app.Activity; import java.util.Timer; import java.util.TimerTask; import java.io.*; public class main { static class Lg { Activity context; ScrollView sv; TextView tv; StringBuilder buf = new StringBuilder(); Lg(Activity context) { this.context = context; sv = new ScrollView(context); tv = new TextView(context); tv.setText(buf.toString()); sv.addView(tv); } View getView() { return sv; } void print(final String s) { context.runOnUiThread(new Runnable() { public void run() { buf.append(s); tv.setText(buf.toString()); } }); } void println(String s) { print(s + "\n"); } } static Lg lg; public static View main(final Activity context) { lg = new Lg(context); OutputStream outputStream = new OutputStream() { public void write(int b) { try { lg.print(new String(new byte[] {(byte) b}, "UTF-8")); // This is crap } catch (UnsupportedEncodingException e) {} } @Override public void write(byte[] b, int off, int len) { try { lg.print(new String(b, off, len, "UTF-8")); // This is crap } catch (UnsupportedEncodingException e) {} } }; PrintStream ps = new PrintStream(outputStream, true); System.setOut(ps); System.setErr(ps); Timer myTimer = new Timer(); myTimer.schedule(new TimerTask() { public void run() { System.out.println("More text"); System.err.println("Also on System.err!"); } }, 0, 1000); return lg.getView(); } }