0

Sorry, I keep on trying to adapt the tokens, but somehow I can't manage this one.

I have the following code:

  timer.schedule(new TimerTask(){

     runOnUiThread(new Runnable() {

      public void run(){
      SplashImage.setImageDrawable(aktieknop);}

      });

  },SplashTime);
  }

Like this the code 'works':

  timer.schedule(new TimerTask(){

    // runOnUiThread(new Runnable() {

      public void run(){
      SplashImage.setImageDrawable(aktieknop);}

    //  });

  },SplashTime);
  }

Can you please help me solving this silly issue? Thanks a lot!

Diego
  • 4,011
  • 10
  • 50
  • 76
  • Since you have already tried something, post the relevant parts of your code and explain specifically what isn't working. If you just want a link about Threads then check out http://developer.android.com/resources/articles/painless-threading.html – skynet Dec 05 '11 at 02:10
  • Read the logCat message first .. or paste here – Finder Dec 07 '11 at 11:59

2 Answers2

0

You must call this code line " SplashImage.setImageDrawable(nSplashImage); " from your run method in a runOnUIThread() method like this:

runOnUiThread(new Runnable() {
public void run() {
    SplashImage.setImageDrawable(nSplashImage);
}

});

This is because you cannot change UI components on a non UI thread.

Cata
  • 11,133
  • 11
  • 65
  • 86
  • Thanks, I made some new final variables and think indeed (looking at the LogCat) that I also need to run it on the UI thread. I now have this in total, only the ;}) I'm not getting right to test. – Diego Dec 07 '11 at 13:22
  • Your welcome.. you can read about AsyncTask too.. it can help you a lot in android multitasking... – Cata Dec 07 '11 at 13:24
0

For the splash Screen you can use the Handler and send the delayed message.

Handler splashHandler = new Handler() {

    @Override
    public void handleMessage(Message msg) {
             super.handleMessage(msg);
              //Here you can do what ever you want

           }
         };

int SPLASHTIME=2000;//your wish

splashHandler.sendMessageDelayed(msg, SPLASHTIME);
Finder
  • 1,217
  • 5
  • 18
  • 46