Click here to Skip to main content
15,881,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am new with java and if somebody can help me with this i really appreciate. My question is how or when can i insert a code to call or launch another activity after the timer lapsed.

Java
protected static final Thread This = null;

@Override
protected void onCreate(Bundle hard) {
    // TODO Auto-generated method stub
    super.onCreate(hard);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_main);
    Thread timer = new Thread(){
        public void run(){
            try{
                Thread.sleep(5000);

            }catch(InterruptedException e){
                e.printStackTrace();
            }finally{
                Intent openStartingPoint = new Intent("--.---.---.------.MainActivity");
                startActivity(openStartingPoint);
            }
        }
    };
    timer.start();

}
Posted
Comments
ghincelino 13-Mar-13 0:20am    
try to debug.. to see the problem..
agnesn88 13-Mar-13 2:00am    
is that for android???
Ed Gepulle 14-Mar-13 8:23am    
yes its for android. i am using eclipse. I having difficulties in inserting code to load or call another activity.

1 solution

it seems you are making splash screen ,
use handler for this and timer is not use for this puropse , if still want to use timer then ,

make sure you use something which makes timing , thred can never use for time ,

Another option is AlarmManager in which you can do like after 10 sec , you can pass another activiy...

check this links

[^]


http://androidideasblog.blogspot.in/2011/07/alarmmanager-and-notificationmanager.html[^]

you can also googling more ...

and lastly you can use this thread in asynch and pass intent in postExecuteMethod...
 
Share this answer
 

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