Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Created September 2, 2010 20:57
Show Gist options
  • Save johnlindquist/562938 to your computer and use it in GitHub Desktop.
Save johnlindquist/562938 to your computer and use it in GitHub Desktop.
package com.johnlindquist;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.Timer;
import java.util.TimerTask;
public class HelloAndroid extends Activity
{
private Handler handler;
private TextView viewById;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
viewById = (TextView) findViewById(R.id.textView1);
viewById.setText("Hello, Android World");
handler = new Handler();
UpdateText updateText = new UpdateText();
handler.postDelayed(updateText, 1000);
}
private class UpdateText extends TimerTask
{
@Override
public void run()
{
String random = new BigInteger(130, new SecureRandom()).toString(32); //random string
viewById.setText(random);
handler.postDelayed(this, 1000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment