且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

任务和活动叠加:什么是两者之间的区别。

更新时间:2023-11-01 12:16:58

活动和任务

如前所述,一个活动可以启动另一个,包括在不同的应用程序来定义。举个例子,你想要让用户显示某些位置的街道地图。还有已经可以做到这一点的活动,让你所有的活动需要做的就是把具备所需的信息的意图对象并把它传递给startActivity()。地图查看器会显示地图。当用户点击BACK键,你的活动将重新出现在屏幕上。

As noted earlier, one activity can start another, including one defined in a different application. Suppose, for example, that you'd like to let users display a street map of some location. There's already an activity that can do that, so all your activity needs to do is put together an Intent object with the required information and pass it to startActivity(). The map viewer will display the map. When the user hits the BACK key, your activity will reappear on screen.

要的用户,它会显得好象地图浏览器是相同的应用程序作为活动的一部分,即使它在另一个应用程序中定义和运行在该应用程序的过程。 Android的维护通过保持两种活动在同一个任务,这个用户体验。简单地说,一个任务是用户体验作为一个应用程序。这是一组相关的活动,安排在一个堆栈。

To the user, it will seem as if the map viewer is part of the same application as your activity, even though it's defined in another application and runs in that application's process. Android maintains this user experience by keeping both activities in the same task. Simply put, a task is what the user experiences as an "application." It's a group of related activities, arranged in a stack.

任务=应用=组活动。