Saturday, May 8, 2010

Activity Management in Android

image

When you first start an application by clicking on a icon. Android starts the Task (Lets say Task1). For an example lets say the task 1 was an Web Browser Task. Initially there will be only 1 Activity(Activity1) and that is the Web Browser. In the Web site, if you had a link which will possibly be a Number of the xxx-xxx-xxxx format. Then When you click it, it will call the specific number that you clicked. It has to call via the Phone Application. Instead of creating New Task 2, It will call in the Phone Application and launch it as activity 2. So, one Activity can call another, and all those Activities get stacked up in the Parent Task which was created when we launched the Browser.

While working on a sets of Activities in the Task, if you were to click on Back Button, it will remove the Activity

from the top of the stack and display the lower task. In other words, going back to the Activity which you removed recently by hitting Back Button is not possible. Each hit on Back button unloads the top most Activity in the Stack. When there is the last Activity, and when you click Back Button you end up going to the Home Screen.

While having a Task / Stack with Set of Activities running in them, if you go back to the Home Screen, and choose a different application, a new Task is created. Which is on top of previous task. And inside this Current task you can create a set of Activities… which run on top of one another. Going back to the Previous Task (Task 1) is very simple. Go back to Home Screen, and click the Icon for Task 1(in this case, as we discussed above we launched Task 1 by clicking the Web Browser, so click that).

One Drawback is: Unloading Activity is not reversible. From a better perspective this should be possible in future, because undo should always be an option. The reason is one Activity can collect good amount of data.., and if you just loose all those by clicking Back.., it doesn't serve the purpose..

State diagram for an Android activity lifecycle. 

del.icio.us Tags: ,,

No comments:

Post a Comment