Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys
i want to show a welcome picture on imageviewer in my android device and after 3seconds i want to change the activity and send user to some other part of program but my TimerTask seems not working! can any one help me?
Java
public class TicketFinalActivity extends Activity {
    
	ImageView iv;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Timer t = new Timer();
        TimerTask welcome = new TimerTask(){
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				Intent intent = new   Intent(TicketFinalActivity.this,Caution.class);
				startActivity(intent);
			}
		};
		t.schedule(welcome, 300, 30000);
        iv = (ImageView)findViewById(R.id.GreetView);
        
    }
}
Posted

1 solution

Try this:
Java
public class TicketFinalActivity extends Activity {

    private final int DELAY_TIME = 1000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                try {
                    Intent i= new Intent(TicketFinalActivity.this, Caution.class);
                    startActivity(i);
                }
                catch (Exception e) {
                    Log.i("TAG", "Error: " + e.getMessage());
                    finish();
                }
            }
        }, DELAY_TIME);
    }
 
Share this answer
 
v3
Comments
khangaldi 2-Jul-12 3:39am    
tanx ;)
Bun Leap_kh 2-Jul-12 3:41am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900