1

I want to update a view every 10 seconds, but how would I go about that?

How would I go about that? I've seen some samples use "Run()" and "Update()", but that doesn't seem to help when I try it, any ideas?

Right now I have:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
//      Vitamio.isInitialized(this);
        Vitamio.isInitialized(getApplicationContext());
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.videoplay);
        Log.d("url=", getIntent().getStringExtra("url"));
        url = getIntent().getStringExtra("url");
        init();

    }
Dr.Mezo
  • 807
  • 3
  • 10
  • 25

1 Answers1

0

If you want to update a View every 10s, you must call a thread. Add following code in your onCreate() method:

Thread t = new Thread() {
  @Override
  public void run() {
    try {
      while (!isInterrupted()) {
        Thread.sleep(10000); // every 10s
        runOnUiThread(new Runnable() {
          @Override
          public void run() {
            // update View here!
          }
        });
      }
    } catch (InterruptedException e) {
    }
  }
};
t.start();
W4R10CK
  • 5,502
  • 2
  • 19
  • 30