prevent屏显示,直到获取数据后,数据、prevent

2023-09-12 06:01:32 作者:爱又是什么

有没有什么办法,我可以从一个活动到另一个延缓屏幕显示器上的目标的活动?

Is there any way I can go from one activity to another and delay the display of the screen on the target activity?

我希望能够做的就是让目标活动,以获取其需要的数据,但直到不到显示任何内容。 我想源活动的屏幕仍然可见,直到我准备在第二活动的数据。

What I want to be able to do is to allow the target activity to fetch its required data but not to display anything until does. I want the screen of the source activity to still be visible until I am ready with the data in the second activity.

具体而言,我使用的是AsyncTask的获取数据。 我知道我可以取源活动的数据,然后将其发送到目标的活动,但这不是可行的在我们的情况。

Specifically, I am using an AsyncTask to fetch the data. I know I could fetch the data in the source activity and then send it on to the target activity but this is not viable in our case.

编辑:详细信息:

整个原因,我想这是因为我想改变目前的code某些部分的结构。 在present它的工作方式是在第一活动获得的数据,然后将其发送到所述第二活性束。 这造成的问题时,第二个活动,可以从多个地方调用。这导致重复code加载。

The whole reason I want this is because I am trying to change the structure of certain parts of the current code. At present the way it works is the the first activity gets the data and then sends it to the second activity as a bundle. This created problems when the second activity could be invoked from multiple places. It resulted in loads of duplicate code.

所以,我决定了数据读取移动到目标活动从而切断任需要反复code。

So, I decided to move the fetching of the data into the target activity thus cutting out any need for repeating code.

它也更有意义的活动来获取它自己的数据,而不是依赖于别的发送。

it also makes more sense for the activity to fetch its own data rather than relying on something else sending it.

推荐答案

您应首先使运行的异步任务的服务。

You should first make a service that runs your async task. Then, start the service from your first activity with startService(new Intent(this, UpdaterServiceManager.class));

当任务在服务结束后,启动第二个活动。

When the task ends in the service, start the second activity.

点击这里一个优良的服务教程。

Click here for an excellent service tutorial.