Why app crashes when Timer is used to remove view?
<p>I'm very new to Andriod development. I'm trying to use Timer (from java.util) to remove a view 1sec after <code>onCreate</code>, this is what I've wrote.</p>

<pre><code>Timer timer;

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        timer = new Timer();
        timer.schedule(new TimerTask() {
              @Override
              public void run() {
                  ImageView startup = (ImageView) findViewById(R.id.startup);
                  startup.setVisibility(View.GONE);
              }
            }, 1000);
}
</code></pre>

<p>Not exactly sure why but my app crashes every time.</p>

<p>It appears that there is something wrong with the timer. I've tried removing the timer and having <code>startup.setVisibility(View.GONE);</code> in <code>OnCreatee</code> and it works fine.</p>

<pre><code>    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            setContentView(R.layout.activity_main);

            ImageView startup = (ImageView) findViewById(R.id.startup);
                      startup.setVisibility(View.GONE);

  //Didn't crash at all!!!
}
</code></pre>

<p>It would be great if someone can explain to me why my app crashes when <code>timer</code> is used.</p>
