如何开始在后台活动并表现出来之后? [英] How to start an activity in background and show it afterwards?

查看:113
本文介绍了如何开始在后台活动并表现出来之后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两项活动,一个是 SplashActivity ,另一个是 MainActivity ,包含web视图的活动。

I've two activities, one is the SplashActivity and the other is MainActivity, an activity containing a webview.

我需要加载web视图显示启动画面时。所以我在寻找一种方式来加载在后台MainActivity在 SplashActivity:在OnCreate();

I need to load the webview when showing the splash screen. So I'm looking for a way to load the MainActivity in background in SplashActivity::onCreate();

如果打算直接调用,MainActivity立即带到前面,还有一个卡在web视图。

If intend is directly called, the MainActivity is immediately brought to the front, as well as a stuck in the webview.

我抬起头来了很多关于闪屏解决方案,如 。不过,他们并不初始化MainActivity直到飞溅时间到期。

I looked up a lot of solutions about splash screen like this . However they don't initialize the MainActivity until the splash time expires.

推荐答案

Android应用可以缓存网络数据。你可以用你的优势。 (和它的工作对我来说)。 我所做的:

Android Apps can cache web data. you can use this to your advantage. (and it worked for me). What I did:

  • 在我创建的启动画面一个web视图。
  • 在它没有连接到用户界面,
  • 要求,我需要在主要活动的网页上。
  • 曾经在闪屏中的WebView加载启动的其他活动。

web视图会使用您在启动画面中创建的web视图的缓存。

the WebView there will use the cache of the WebView you created in the splash screen.

这篇关于如何开始在后台活动并表现出来之后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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