如何延迟从另一个活动调用一个活动? [英] How to put some delay in calling an activity from another activity?

查看:27
本文介绍了如何延迟从另一个活动调用一个活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我在其中收到一条包含他的位置的短信.收到短信后,它会调用另一个活动来启动并将该位置传递给该活动以将其绘制在地图上.在调用第二个活动之前,它会显示一个Toast 就像屏幕上的通知,但由于调用了第二个 Activity 导致 toast 没有出现.我的问题是我们如何延迟从这个 Activity 调用第二个 Activity?

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 plot it on the map.Before calling the second activity it shows a toast like notification on the screen but somehoe due to calling second activity that toast doesn't come up.My question is how can we delay the calling of second activity from this activity ?

推荐答案

你可以这样使用:

 new Handler().postDelayed(new Runnable() {
                      @Override
                      public void run() {

                          Intent i=new Intent(SearxhJobs.this,JobsTypes.class);
                          startActivity(i);
                      }
                  }, 5000);

此处等待 5 秒以启动 Activity.

Here it waits upto 5 seconds to launch activity.

希望能帮到你

这篇关于如何延迟从另一个活动调用一个活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆