简体   繁体   English

android启动活动并保持先前​​运行

[英]android start activity and keep running previous

I would like to call splashScreen activity while current activity is been executed. 我想在执行当前活动时调用splashScreen活动。 Once current activity finishes its load, finish splashScreen activity. 当前活动完成其加载后,请完成splashScreen活动。 How can I call one activity and keep executing current activity? 如何调用一个活动并继续执行当前活动? Thank you. 谢谢。

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(TabBarActivity.this, splashScreen.class);
        startActivity(intent);

        setContentView(R.layout.main);

        cicle();

    }

Have a ProgressBar load in your SplashScreen activity via an AsyncTask. 通过AsyncTask在您的SplashScreen活动中加载一个ProgressBar。 Keep updating the progressbar in that activity and once the loading is fully completed, you can start a new activity in maybe..postExecute() method. 继续更新该活动中的进度栏​​,一旦加载完全完成,您就可以在也许..postExecute()方法中启动一个新活动。

You can refer to this: Progressbar in Splashscreen android 您可以参考以下内容: Splashscreen android中的Progressbar

I'd suggest this: 我建议这样做:

  1. Make the Splashscreen the entry point of your application. 使启动画面成为应用程序的入口点。
  2. From the SplashscreenActivity execute the long-running task in the background (see AsyncTask and its doInBackground() method) 在SplashscreenActivity中,在后台执行长时间运行的任务(请参阅AsyncTask及其doInBackground()方法)
  3. When that's finished, switch to the next activity and transfer the background operation result (intent.putExtra...) 完成后,切换到下一个活动并传输后台操作结果(intent.putExtra ...)

do the "loading" in splash activity instead, whenever the loading ends, launch the next activity. 而是在启动活动中执行“加载”,只要加载结束,就启动下一个活动。 There is no need for something that complex 不需要复杂的东西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM