How to put some delay in calling an activity from another activity?

后端 未结 7 2377
难免孤独
难免孤独 2020-12-03 05:31

I have an application in which I\'m receiving a sms containing his location.On receiving sms it calls another activity to start and passes that location to that activity to

7条回答
  •  Happy的楠姐
    2020-12-03 06:03

    You can do it with a Handler like this

        Handler h = new Handler(){
            @Override
            public void handleMessage(Message msg) {
    
                Intent i = new Intent().setClass(ctx, MainActivity.class);                  
                startActivity(i);
            }           
        };
    
        h.sendEmptyMessageDelayed(0, 1500); // 1500 is time in miliseconds
    

提交回复
热议问题