Android Developer Question: Download Android Developer PDF

Please explain the difference between FLAG_ACTIVITY_CLEAR_TASK and FLAG_ACTIVITY_CLEAR_TOP?

Tweet Share WhatsApp

Answer:

☛ FLAG_ACTIVITY_CLEAR_TASK is used to clear all the activities from the task including any existing instances of the class invoked. The Activity launched by intent becomes the new root of the otherwise empty task list. This flag has to be used in conjunction with FLAG_ ACTIVITY_NEW_TASK.
☛ FLAG_ACTIVITY_CLEAR_TOP on the other hand, if set and if an old instance of this Activity exists in the task list then barring that all the other activities are removed and that old activity becomes the root of the task list. Else if there’s no instance of that activity then a new instance of it is made the root of the task list. Using FLAG_ACTIVITY_NEW_TASK in conjunction is a good practice, though not necessary.

Download Android Developer PDF Read All 56 Android Developer Questions
Previous QuestionNext Question
Tell us what is the relationship between the life cycle of an AsyncTask and an Activity? What problems can this result in? How can these problems be avoided?What is lifecycle of an Activity?