Task and Activity stack : what is difference between both.

匿名 (未验证) 提交于 2019-12-03 02:47:02

问题:

I followed some tutorials but got confused with "Activity stack" and "Task".

  • Because both starts when a new activity is created.
  • Activity stack keeps a navigation history of activities, and Task is a sequence of activities.

Is this is only difference that Activity stack made up of one or more task(S)?

Give some example please.

回答1:

Activities and Tasks

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.

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.

Task = Application = set of activity.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!