From 7363e049ec7c2f490acf783a979ea101df35a055 Mon Sep 17 00:00:00 2001 From: Doug Kramer Date: Fri, 29 May 2009 19:27:02 -0700 Subject: AI 149404: Am sending again with the latest changes Publish Activity and Task Design Guidelines http://doog:9000/guide/practices/ui_guidelines/activity_task_design.html Automated import of CL 149404 --- docs/html/guide/guide_toc.cs | 1 + .../ui_guidelines/activity_task_design.jd | 1223 ++++++++++++++++++++ docs/html/guide/practices/ui_guidelines/index.jd | 14 +- .../activity_task_design/ActivityChooser.png | Bin 0 -> 82669 bytes .../images/activity_task_design/ContactNew.png | Bin 0 -> 82669 bytes .../images/activity_task_design/ContactView.png | Bin 0 -> 82669 bytes .../images/activity_task_design/ContactsDialer.png | Bin 0 -> 82669 bytes .../images/activity_task_design/ContactsList.png | Bin 0 -> 82669 bytes .../activity_task_design/HomeTaskBasics1a.png | Bin 0 -> 25905 bytes .../activity_task_design/HomeTaskBasics1b.png | Bin 0 -> 26166 bytes .../activity_task_design/HomeTaskBasics1c.png | Bin 0 -> 25576 bytes .../activity_task_design/HomeTaskBasics1d.png | Bin 0 -> 45696 bytes .../activity_task_design/HomeTaskBasics1e.png | Bin 0 -> 23046 bytes .../activity_task_design/HomeTaskSwitching1a.png | Bin 0 -> 20359 bytes .../activity_task_design/HomeTaskSwitching1b.png | Bin 0 -> 18376 bytes .../activity_task_design/HomeTaskSwitching1c.png | Bin 0 -> 24597 bytes .../activity_task_design/HomeTaskSwitching2.png | Bin 0 -> 41605 bytes .../activity_task_design/HomeTaskSwitching3a.png | Bin 0 -> 26125 bytes .../activity_task_design/HomeTaskSwitching3b.png | Bin 0 -> 21663 bytes .../activity_task_design/HomeTaskSwitching3c.png | Bin 0 -> 16329 bytes .../images/activity_task_design/IntentsDiagram.png | Bin 0 -> 37600 bytes .../PhoneActivitiesDiagram.png | Bin 0 -> 31067 bytes .../activity_task_design/ReplacingAnActivity.png | Bin 0 -> 45079 bytes .../activity_task_design/ReusingAnActivity1.png | Bin 0 -> 30077 bytes .../activity_task_design/ReusingAnActivity2.png | Bin 0 -> 27762 bytes 25 files changed, 1237 insertions(+), 1 deletion(-) create mode 100644 docs/html/guide/practices/ui_guidelines/activity_task_design.jd create mode 100644 docs/html/images/activity_task_design/ActivityChooser.png create mode 100644 docs/html/images/activity_task_design/ContactNew.png create mode 100644 docs/html/images/activity_task_design/ContactView.png create mode 100644 docs/html/images/activity_task_design/ContactsDialer.png create mode 100644 docs/html/images/activity_task_design/ContactsList.png create mode 100644 docs/html/images/activity_task_design/HomeTaskBasics1a.png create mode 100644 docs/html/images/activity_task_design/HomeTaskBasics1b.png create mode 100644 docs/html/images/activity_task_design/HomeTaskBasics1c.png create mode 100644 docs/html/images/activity_task_design/HomeTaskBasics1d.png create mode 100644 docs/html/images/activity_task_design/HomeTaskBasics1e.png create mode 100644 docs/html/images/activity_task_design/HomeTaskSwitching1a.png create mode 100644 docs/html/images/activity_task_design/HomeTaskSwitching1b.png create mode 100644 docs/html/images/activity_task_design/HomeTaskSwitching1c.png create mode 100644 docs/html/images/activity_task_design/HomeTaskSwitching2.png create mode 100644 docs/html/images/activity_task_design/HomeTaskSwitching3a.png create mode 100644 docs/html/images/activity_task_design/HomeTaskSwitching3b.png create mode 100644 docs/html/images/activity_task_design/HomeTaskSwitching3c.png create mode 100644 docs/html/images/activity_task_design/IntentsDiagram.png create mode 100644 docs/html/images/activity_task_design/PhoneActivitiesDiagram.png create mode 100644 docs/html/images/activity_task_design/ReplacingAnActivity.png create mode 100644 docs/html/images/activity_task_design/ReusingAnActivity1.png create mode 100644 docs/html/images/activity_task_design/ReusingAnActivity2.png diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs index da5192a1091d..da4a2c33c5cf 100644 --- a/docs/html/guide/guide_toc.cs +++ b/docs/html/guide/guide_toc.cs @@ -148,6 +148,7 @@
  • Designing for Performance
  • diff --git a/docs/html/guide/practices/ui_guidelines/activity_task_design.jd b/docs/html/guide/practices/ui_guidelines/activity_task_design.jd new file mode 100644 index 000000000000..bec0e436a7a5 --- /dev/null +++ b/docs/html/guide/practices/ui_guidelines/activity_task_design.jd @@ -0,0 +1,1223 @@ +page.title=Activity and Task Design Guidelines +@jd:body + +
    +
    + +

    Activity and task design quickview

    + +
      +
    • Activities are the main building blocks of Android applications.
    • +
    • In addition to writing your own activities, you are free to re-use activities from many other applications through intents.
    • +
    • You can enable activities in your application to be started from intents in other applications.
    • +
    • In nearly all cases, the activity stack just works as expected.
    • + In a couple of cases you might need to ensure the right thing happens by setting a string or flag. +
    + +

    In this document

    + +
      +
    1. Applications, Activities, Activity Stack and Tasks +
    2. +
    3. A Tour of Activities and Tasks +
        +
      1. Starting an Activity from Home
      2. +
      3. Navigating Away from an Activity
      4. +
      5. Re-using an Activity
      6. +
      7. Replacing an Activity
      8. +
      9. Multitasking
      10. +
      11. Launching from Two Entry Points
      12. +
      13. Intents
      14. +
      15. Switching Between Tasks
      16. +
      +
    4. +
    5. Design Tips +
        +
      1. Don't specify intent filters in an activity that won't be re-used
      2. +
      3. Don't define your own URI schemes
      4. +
      5. Handle where a re-used activity is missing
      6. +
      7. Consider how to launch your activities
      8. +
      9. Allow activities to add to current task
      10. +
      11. Notifications should be easy to return from
      12. +
      13. Use the notification system
      14. +
      15. Don't take over BACK key unless you absolutely need to
      16. +
      +
    6. +
    + +

    See also

    + +
      +
    1. Application Fundamentals
    2. +
    3. Activities and Tasks blog post
    4. +
    + +
    +
    + +

    + This document describes core principles of the Android application + framework, from a high-level, user-centric perspective useful to + interaction and application designers as well as application + developers. +

    + +

    + It illustrates activities and tasks with examples, and describes some + of their underlying principles and mechanisms, such as navigation, + multitasking, activity re-use, intents, and the activity stack. + The document also highlights design decisions that are available to you + and what control they give you over the UI of your application. +

    + +

    + This document draws examples from several Android applications, + including default applications (such as Dialer) and Google + applications (such as Maps). You can try out the examples yourself in + the Android emulator or on an Android-powered device. If you are using + a device, note that your device may not offer all of the example + applications used in this document. +

    + +

    + Be sure to look at the Design Tips section + for guidelines, tips, and things to avoid. This document is a + complement to Application Fundamentals, + which covers the underlying mechanics for programmers. +

    + +

    Applications, Activities, Activity Stack and Tasks

    + +

    + Four fundamental concepts in the Android system that are helpful for you to understand are: +

    + + + +

    Applications

    + +

    + An Android application typically consists of one or more + related, loosely bound activities for the user to interact with, typically bundled up + in a single file (with an .apk suffix). Android ships with a rich set + of applications that may include email, calendar, browser, maps, text + messaging, contacts, camera, dialer, music player, settings and + others. +

    + +

    + Android has an application launcher available at the Home screen, + typically in a sliding drawer which displays applications as icons, + which the user can pick to start an application. +

    + + +

    Activities

    + +

    + Activities are the main building blocks of Android + applications. When you create an application, you can assemble it from + activities that you create and from activities you re-use from other + applications. These activities are bound at runtime, so that newly + installed applications can take advantage of already installed + activities. Once assembled, activities work together to form a + cohesive user interface. An activity has a distinct visual user + interface designed around a single, well-bounded purpose, such as + viewing, editing, dialing the phone, taking a photo, searching, + sending data, starting a voice command, or performing some other type + of user action. Any application that presents anything on the display + must have at least one activity responsible for that display. +

    + +

    + When using an Android device, as the user moves through the user + interface they start activities one after the other, totally oblivious + to the underlying behavior — to them the experience should be + seamless, activity after activity, task after + task. +

    + +

    + An activity handles a particular type of content (data) and accepts a + set of related user actions. In general, each activity has a + lifecycle that is independent of the other + activities in its application or task — each activity is + launched (started) independently, and the user or system can start, + run, pause, resume, stop and restart it as needed. Because of this + independence, activities can be re-used and replaced by other + activities in a variety of ways. +

    + +

    + The Dialer application is an example of an application that consists + basically of four activities: dialer, contacts list, view contact, and + new contact, as shown in the following screenshots: +

    + + + + + + + + + + +
    + +
    + Dialer +
    +
    + +
    + Contacts +
    +
    + +
    + View Contact +
    +
    + +
    + New Contact +
    +
    + +

    + Here are other examples of applications and the activities they might contain: +

    + + + + +

    + An activity is the most prominent of four components of an + application. The other components are service, content provider and + broadcast receiver. For more details on activities, see Activity in + Application Components. +

    + + +

    Activity Stack

    + +

    + As the user moves from activity to activity, across applications, the + Android system keeps a linear navigation history of activities the + user has visited. This is the activity stack, also known as the + back stack. In general, when a user starts a new activity, it is added + to the activity stack, so that pressing BACK displays the previous + activity on the stack. However, the user cannot use the BACK key to go + back further than the last visit to Home. The adding of an activity to + the current stack happens whether or not that activity begins a new + task (as long as that task was started + without going Home), so going back can let the user go back to + activities in previous tasks. The user can get to tasks earlier than + the most recent Home by selecting its root activity from the + application launcher, a shortcut, or the "Recent tasks" screen. +

    + +

    + Activities are the only things that can be added to the activity stack + — views, windows, menus, and dialogs cannot. That is, when + designing the navigation, if you have screen A and you want the user + to be able go to a subsequent screen B and then use the BACK key to go + back to screen A, then the screen A needs to be implemented as an + activity. The one exception to this rule is if your application + and manages the navigation itself. +

    + + + +

    Tasks

    + +

    + A task is the sequence of activities the user follows to + accomplish an objective, regardless of which applications the + activities belong to. Until a new task is explicitly specified (see + "Interrupting the Task"), all activities the user starts are + considered to be part of the current task. It's notable that these + activities can be in any application — that is, all in the same + application or in different ones. That is, a task that starts out in + contacts can continue, by choosing an email address, to an email + activity and then, by attaching a file, to a picture gallery to pick + from. Contacts, email and picture gallery are all separate + applications. +

    + +

    + The activity that starts a task is called the root activity. + It is often, but not necessarily, started from the application + launcher, Home screen shortcut or "Recent tasks" switcher (a long + press on Home on some devices). The user can return to a task by + choosing the icon for its root activity the same way they started the + task. Once inside a task, the BACK key goes to previous activities in + that task. The activity stack is made up of one or more tasks. +

    + +

    + Here are some examples of tasks: +

    + + + +

    + Interrupting the Task - An important property of a task is that + the user can interrupt what they're doing (their task) to perform a + different task, then are able to return to where they left off to + complete the original task. The idea is that users can run multiple + tasks simultaneously and switch between them. There are two primary + ways to jump off to that other task — in both cases the user + should be able to return to where they were before the interruption: +

    + + + + +

    + Of course, there are exceptions to the rules. Beyond the two ways just + mentioned, there is a third way to start a task, and that is by + starting an activity that defines itself as a new task. Maps and + Browser are two applications that do this. For example, choosing an + address in an email starts the Maps activity as a new task, and + choosing a link in an email starts the Browser activity as a new + task. In these cases, the BACK key will return to the previous + activity in a different task (Email), because it was not started from + Home. +

    + + +

    A Tour of Activities and Tasks

    + +

    + The following examples illustrate basic principles for applications, + activities, the activity stack, the BACK key, tasks and intents. It + shows how the system responds to user actions such as starting + activities and switching between tasks. With most of these examples + you can follow along, launching activities on your device as + indicated. +

    + + +

    Starting an Activity from Home

    + +

    + Home is the starting place for most applications. (Some applications + can be launched only from other applications.) When the user touches + an icon in the application launcher (or a shortcut on the Home + screen), the main activity for that application is launched into the + foreground where it has user focus. As shown in the following figure, + the user action of going Home and touching the Email icon launches the + List Messages activity of the Email application. The Home activity + remains stopped in the background, ready to restart when called on by + the user. +

    + +

    + +

    + + + +

    + An activity can keep or lose its state depending on how the user + leaves the activity — by the HOME or BACK key. +

    + +

    + By default, pressing the BACK key finishes (destroys) the current + activity and displays the previous activity to the user. In the + following figure, the user starts email by touching the Email icon in + the Home screen, which displays a list of email messages. The user + scrolls down the list (changing its initial state). Pressing BACK + destroys the List Messages activity and returns to the previous + activity, which is Home. If the user re-launches Email, it would + re-load the messages and display its initial, non-scrolled state. +

    + +

    + +

    + +

    + In the above example, pressing BACK goes to Home because it was the + last activity the user was viewing. But if the user had gotten to List + Message from some other activity, then pressing BACK would have + returned there. +

    + +

    + By contrast, the next figure shows the user leaving List Messages by + pressing HOME instead of BACK — the List Messages activity is + stopped and moved to the background rather than being + destroyed. Starting Email again from its icon would simply bring the + List Messages activity to the foreground (changing it from stopped to + running) in the same scrolled state the user last left it. +

    + +

    + +

    + +

    + Exceptions. Some background activities return to their initial + screen (they lose any state, such as scrolling) when they are brought + to the foreground. This is true for Contacts and Gallery. If the user + chooses Home > Contacts then chooses a contact, they are viewing + the details of a contact. If they start again by choosing Home > + Contacts, they are presented with the initial list of contacts rather + than the contact they were last viewing. Contacts is designed this way + because this initial screen is the main entry point for the + application with four tabs for accessing the full range of features. +

    + +

    + In addition, not all activities have the behavior that they are + destroyed when BACK is pressed. When the user starts playing music in + the Music application and then presses BACK, the application overrides + the normal back behavior, preventing the player activity from being + destroyed, and continues playing music, even though its activity is no + longer visible — as a visual substitute, the Music application + places a notification in the status bar so the user still has an easy + way to get to the application to stop or control the music. Note that + you can write an activity to stop when its screen is no longer + visible, or to continue running in the background — the latter + was chosen for the music player. +

    + + +

    Re-using an Activity

    + +

    + When activity A starts activity B in a different application, activity + B is said to be re-used. This use case normally takes place + because activity A is lacking a capability and can find it in activity B. +

    + +

    + Contacts Re-Uses Gallery to Get a Picture - The Contacts + activity has a field for a picture of a contact, but the Gallery is + normally where pictures are kept. So Contacts can re-use the Gallery + activity to get a picture. This is a good example of re-use of the + Gallery activity. The following figure illustrates the sequence of + activities to do this (up to crop). This is how it's done: The user + chooses Contacts, selects the contact for viewing, chooses MENU > + Edit contact and touches the picture field, which launches the Gallery + activity. The user then chooses the picture they want, crops and saves + it. Saving it causes the picture to be inserted into the picture field + in the contact. +

    + +

    + Notice the Gallery returns a picture to the Contacts application that + started it. The next example illustrates re-use of an activity that + does not return a result. Also notice that the following figure is + illustrates the navigation history through the activities, or the + activity stack — the user can back up through each activity all + the way to Home. +

    + +

    + When designing an application, it's good to think about how it can + re-use activities in other applications, and how your activities might + be re-used by other applications. If you add an activity with the same + intent filter as an + exisiting activity, then the system presents the user with a choice + between the activities. +

    + +

    + +

    + +

    + Gallery Re-Uses Messaging for Sharing a Picture - Sharing is + another good example of one application re-using an activity from a + different application. As shown in the following figure, the user + starts Gallery, picks a picture to view, chooses MENU > Share, and + picks "Messaging". This starts the Messaging activity, creates a new + message and attaches the original picture to it. The user then fills + in the "To" field, writes a short message and sends it. User focus + remains in the Messaging program. If the user wants to go back to the + Gallery, they must press the BACK key. (The user can back up through + each activity all the way to Home.) +

    + +

    + In contrast to the previous example, this re-use of the Messaging + activity does not return anything to the Gallery activity that started it. +

    + +

    + +

    + +

    + Both of these examples illustrate tasks — a sequence of + activities that accomplish an objective. Each case uses activities + from two different applications to get the job done. +

    + + +

    Replacing an Activity

    + +

    + This is the use case where activity A replaces activity B in a + different application. This situation normally happens because + activity A is better at doing the job than activity B. In other words, + A and B are equivalent enough that A can replace B. This case stands + in contrast with re-using an activity, where A and B are quite + different activities and supplement each other. +

    + +

    + In this example, the user has downloaded a replacement for the Phone + Ringtone activity, called Rings Extended. Now when they go to + Settings, Sound & Display, Phone Ringtone, the system presents + them with a choice between the Android System's ringtone activity and + the new one. This dialog box has an option to remember their choice + "Use by default for this action". When they choose "Rings Extended", + that activity loads, replacing the original Android ringtone activity. +

    + +

    + +

    + +

    Multitasking

    + +

    + As previously noted, when an activity has been launched, the user can + go to Home and launch a second activity without destroying the first + activity. This scenario demonstrates launching the Maps application. +

    + + + + +

    + +

    + + +

    + +

    + +

    + The application launcher at Home has launched "View Map" and "Day + View" activities into separate tasks, hence the system is + multitasking — running multiple tasks. +

    + + +

    Launching from Two Entry Points

    + +

    + Every application must have at least one entry point — a way + for the user or system to access activities inside the + application. Each icon in the application launcher at home + represents an entry point. Applications can also from another + application. Each activity is a potential entry point into the + application.  +

    + +

    + The phone application has two entry points: Contacts and Dialer. A + user entering from Contacts can choose a phone number to launch the + Dialer. As shown in the following figure, a user could choose the + Contacts icon to launch the Contacts activity, then pick a phone + number to launch the Dialer activity and dial the phone. +

    + +

    + Once the user is inside the application, they can access other + activities, such as New Contact and Edit Contact, through tabs, menu + items, list items, onscreen buttons, or other user interface + controls. +

    + +

    + +

    + +

    Intents

    + +

    + When the user takes an action on some data, such as touching a + mailto:info@example.com link, they are actually initiating an Intent + object which then gets resolved to a particular component (we will + consider only activity components here). So, the result of a user + touching a mailto: link is an Intent object that the system tries to + match to an activity. If that Intent object was written explicitly + naming an activity (an explicit intent), then the system + immediately launches that activity in response to the user + action. However, if that Intent object was written without naming an + activity (an implicit intent), the system compares the Intent + object to the intent filters of available activities. If more + than one activity can handle the action and data, the system + displays an activity chooser for the user to choose from. +

    + +

    + This example of touching the mailto: link is shown in the following + figure. If the device has two email applications set up, when a user + touches a mailto: email address on a web page, the result is an + Intent object which displays a dialog box with a choice between the + two activities to compose an email (Gmail and Email). +

    + +

    + +

    + +

    + Here are some examples of Intent objects and the activities they resolve to: +

    + + + +

    + Notice that an Intent object specifies two things, an action and data: +

    + + + +

    + Note that any user action to start an activity from the + application launcher at Home is an explicit intent to a specific + activity. Likewise, some activities launch private activities + within their application as explicit intents so no other activity + can access them. +

    + +

    + For more on intents, see {@link android.content.Intent Intent class} and + intent filters. +

    + + +

    Switching Between Tasks

    + +

    + This scenario shows how the user can switch between two tasks. In + this example, the user writes a text message, attaches a picture, + but before they are done they glance at their calendar. They then + return to where they left off, attaching the picture and sending the + message. +

    + +
      +
    1. + Start first task. You want to send a text message and attach a photo. You would choose: + +

      + Home > Messaging > New message > MENU > Attach + > Pictures. This last step launches the picture gallery + for picking a photo. Notice that picture gallery is an + activity in a separate application. +

      + + + + + + + + + + +
      + + + + + +
      + +

      + At this point, before you have picked a picture, you decide + to stop and glance at your calendar, which is a separate + task. Because the current activity has no button to go + directly to the Calendar, you need to start from Home. +

      + +
    2. +
    3. + Start second task. You choose Home > Calendar to + look at a calendar event. Calendar launches from Home as a new + task because the application launcher creates a new task for + each application it launches. + +

      + +

      +
    4. + +
    5. + Switch to first task and complete it. When done looking + at the Calendar, you can return to attaching the picture by + starting the root activity again for that task: choose Home + > Messaging, which takes you not to Messaging, but directly + to the Picture gallery, where you left off. You can then pick + a photo, which is added to the message, you send the message + and you're done with the first task. + + + + + + + + + + + + + +
      + + + + +         +
      +
    6. +
    + + +

    Design Tips

    + +

    + The following are tips and guidelines for application designers and developers. +

    + +

    When writing an activity that won't be re-used, don't specify intent filters — use explicit intents

    + +

    + If you're writing an activity that you don't want other activities + to use, be sure not to add any intent filters to that activity. This + applies to an activity that will be launched only from the + application launcher or from other activities inside your + application. Instead, just create intents specifying the explicit + component to launch — that is, explicit intents. In this case, + there's just no need for intent filters. Intent filters are + published to all other applications, so if you make an intent + filter, what you're doing is publishing access to your activity, + which means you can cause unintentional security holes. +

    + + + +

    When reusing an activity owned by others, handle the case where no activity matches

    + +

    + Your applications can re-use activities made available from other + applications. In doing so, you cannot presume that external activity + will always be present — you must handle the case that the + external activity is not installed. Do this in the way you find most + appropriate, such as dimming the user control that accesses it (such + as a button or menu item), or displaying a message to the user that + sends them to the location to download it, such as the Market. +

    + +

    Consider how you want your activities to be launched or used by other applications

    + +

    + As a designer or developer, it's up to you to determine how users + start your application and the activities in it. As an application + is a set of activities, the user can start these activities from + Home or from another application. +

    + + + + + + +

    Allow your activities to be added to the current task

    + +

    + If your activities can be started from another application, allow + them to be added to the current task + (or an existing task it has an affinity with). Having activities + added to a task enables the user to switch between a task that + contains your activities and other tasks. Exceptions are + your activities that have only one instance.  +

    + +

    + For this behavior, your activity should have a launch + mode of standard or singleTop rather than singleTask or + singleInstance. These modes also enable multiple instances of your + activity to be run. +

    + + +

    Notifications should be easy for the user to return from

    + +

    + Applications that are in the background or haven't been run can + send out notifications to the user letting them know about events + of interest. For example, Calendar can send out notifications of + upcoming events, and Email can send out notifications when new + messages arrive. One of the user interface rules is that when the + user is in activity A and gets a notification for activity B and + picks that notification, when they press the BACK key, they should + go back to activity A.  +

    + +

    + The following scenario shows how the activity stack should work + when the user responds to a notification. +

    + +
      +
    1. + User is creating a new event in Calendar. They realize they + need to copy part of an email message into this event +
    2. +
    3. + The user chooses Home > Gmail +
    4. +
    5. + While in Gmail, they receive a notification from Calendar for an upcoming meeting +
    6. +
    7. + So they choose that notification, which takes them to a + dedicated Calendar activity that displays brief details of the + upcoming meeting +
    8. +
    9. + The user chooses this short notice to view further details +
    10. +
    11. + When done viewing the event, the user presses the BACK + key. They should be taken to Gmail, which is where they were + when they took the notification +
    12. +
    + +

    +This behavior doesn't necessarily happen by default. +

    + +

    +Notifications generally happen primarily in one of two ways: +

    + + + +

    + There are other ways to handle notifications, such as bringing the + activity to the foreground set to display specific data, such as the + ongoing text message thread of a particular person. +

    + +

    + A notification always starts an activity as a new task (that is, it + puts FLAG_ACTIVITY_NEW_TASK in the intent it + passes to startActivity()). This is done because interruptions to a + task should not become part of that task. +

    + +

    Use the notification system — don't use dialog boxes in place of notifications

    + +

    + If your background service needs to notify a user, use the standard + notification system — don't use a dialog or toast to notify + them. A dialog or toast would immediately take focus and interrupt + the user, taking focus away from what they were doing: the user + could be in the middle of typing text the moment the dialog appears + and could accidentally act on the dialog. Users are used to dealing + with notifications and can pull down the notification shade at their + convenience to respond to your message. +

    + +

    Don't take over the BACK key unless you absolutely need to

    + +

    + As a user navigates from one activity to the next, the system adds + them to the activity stack. This forms a navigation history that is + accessible with the BACK key. Most activities are relatively limited + in scope, with just one set of data, such as viewing a list of + contacts, composing an email, or taking a photo. But what if your + application is one big activity with several pages of content and + needs finer-grained control of the BACK key? Examples of such Google + applications are the Browser, which can have several web pages open + at once, and Maps, which can have several layers of geographic data + to switch between. Both of these applications take control of the + BACK key and maintain their own internal back stacks that operate + only when these applications have focus. +

    + +

    + For example, Maps uses layers to present different + information on a map to the user: displaying the location of a + search result, displaying locations of friends, and displaying a + line for a street path providing direction between points. Maps + stores these layers in its own history so the BACK key can return to + a previous layer. +

    + +

    + Similarly, Browser uses browser windows to present different + web pages to the user. Each window has its own navigation history, + equivalent to tabs in a browser in a desktop operating system (such + as Windows, Macintosh or Linux). For example, if you did a Google + web search in one window of the Android Browser, clicking on a link + in the search results displays a web page in that same window, and + then pressing BACK would to the search results page. Pressing + BACK goes to a previous window only if the current window was + launched from that previous window. If the user keeps pressing + back, they will eventually leave the browser activity and return + Home. +

    + diff --git a/docs/html/guide/practices/ui_guidelines/index.jd b/docs/html/guide/practices/ui_guidelines/index.jd index 61e310a8ea67..0b9d2754d21a 100644 --- a/docs/html/guide/practices/ui_guidelines/index.jd +++ b/docs/html/guide/practices/ui_guidelines/index.jd @@ -22,12 +22,24 @@ The Icon Templates Pack is an archive of Photoshop and Illustrator templates and filters that make it much simpler to create conforming icons.
    -
    Widget Design Guidelines
    +
    Widget Design Guidelines
    A widget displays an application's most important or timely information at a glance, on a user's Home screen. These design guidelines describe how to design widgets that fit with others on the Home screen. They include links to graphics files and templates that will make your designer's life easier.
    +
    +
    Activity and Task Design Guidelines
    +
    Activities are the basic, independent building blocks of applications. + As you design your application's UI and feature set, you are free to + re-use activities from other applications as if they were yours, + to enrich and extend your application. These guidelines + describe how activities work, illustrates them with examples, and + describes important underlying principles and mechanisms, such as + multitasking, activity reuse, intents, the activity stack, and + tasks. It covers this all from a high-level design perspective. +
    +
    diff --git a/docs/html/images/activity_task_design/ActivityChooser.png b/docs/html/images/activity_task_design/ActivityChooser.png new file mode 100644 index 000000000000..6c20afbbd21c Binary files /dev/null and b/docs/html/images/activity_task_design/ActivityChooser.png differ diff --git a/docs/html/images/activity_task_design/ContactNew.png b/docs/html/images/activity_task_design/ContactNew.png new file mode 100644 index 000000000000..decaaeb0b1e4 Binary files /dev/null and b/docs/html/images/activity_task_design/ContactNew.png differ diff --git a/docs/html/images/activity_task_design/ContactView.png b/docs/html/images/activity_task_design/ContactView.png new file mode 100644 index 000000000000..5eff2ba6d1fc Binary files /dev/null and b/docs/html/images/activity_task_design/ContactView.png differ diff --git a/docs/html/images/activity_task_design/ContactsDialer.png b/docs/html/images/activity_task_design/ContactsDialer.png new file mode 100644 index 000000000000..28794b7f2576 Binary files /dev/null and b/docs/html/images/activity_task_design/ContactsDialer.png differ diff --git a/docs/html/images/activity_task_design/ContactsList.png b/docs/html/images/activity_task_design/ContactsList.png new file mode 100644 index 000000000000..ef1b83f48db1 Binary files /dev/null and b/docs/html/images/activity_task_design/ContactsList.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskBasics1a.png b/docs/html/images/activity_task_design/HomeTaskBasics1a.png new file mode 100644 index 000000000000..eca480705b12 Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskBasics1a.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskBasics1b.png b/docs/html/images/activity_task_design/HomeTaskBasics1b.png new file mode 100644 index 000000000000..ce76d634f341 Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskBasics1b.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskBasics1c.png b/docs/html/images/activity_task_design/HomeTaskBasics1c.png new file mode 100644 index 000000000000..95f48c1084b4 Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskBasics1c.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskBasics1d.png b/docs/html/images/activity_task_design/HomeTaskBasics1d.png new file mode 100644 index 000000000000..bbb96d9b33d9 Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskBasics1d.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskBasics1e.png b/docs/html/images/activity_task_design/HomeTaskBasics1e.png new file mode 100644 index 000000000000..09dd491cf335 Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskBasics1e.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskSwitching1a.png b/docs/html/images/activity_task_design/HomeTaskSwitching1a.png new file mode 100644 index 000000000000..de79aaf953ea Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskSwitching1a.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskSwitching1b.png b/docs/html/images/activity_task_design/HomeTaskSwitching1b.png new file mode 100644 index 000000000000..bce77724a8be Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskSwitching1b.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskSwitching1c.png b/docs/html/images/activity_task_design/HomeTaskSwitching1c.png new file mode 100644 index 000000000000..8209f2fbab0b Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskSwitching1c.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskSwitching2.png b/docs/html/images/activity_task_design/HomeTaskSwitching2.png new file mode 100644 index 000000000000..dee58a397a94 Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskSwitching2.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskSwitching3a.png b/docs/html/images/activity_task_design/HomeTaskSwitching3a.png new file mode 100644 index 000000000000..0c90a86a1ddb Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskSwitching3a.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskSwitching3b.png b/docs/html/images/activity_task_design/HomeTaskSwitching3b.png new file mode 100644 index 000000000000..4a16e69ddb46 Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskSwitching3b.png differ diff --git a/docs/html/images/activity_task_design/HomeTaskSwitching3c.png b/docs/html/images/activity_task_design/HomeTaskSwitching3c.png new file mode 100644 index 000000000000..d7789aa8f31f Binary files /dev/null and b/docs/html/images/activity_task_design/HomeTaskSwitching3c.png differ diff --git a/docs/html/images/activity_task_design/IntentsDiagram.png b/docs/html/images/activity_task_design/IntentsDiagram.png new file mode 100644 index 000000000000..0ed366ff721d Binary files /dev/null and b/docs/html/images/activity_task_design/IntentsDiagram.png differ diff --git a/docs/html/images/activity_task_design/PhoneActivitiesDiagram.png b/docs/html/images/activity_task_design/PhoneActivitiesDiagram.png new file mode 100644 index 000000000000..8d346c178869 Binary files /dev/null and b/docs/html/images/activity_task_design/PhoneActivitiesDiagram.png differ diff --git a/docs/html/images/activity_task_design/ReplacingAnActivity.png b/docs/html/images/activity_task_design/ReplacingAnActivity.png new file mode 100644 index 000000000000..03b4d929a747 Binary files /dev/null and b/docs/html/images/activity_task_design/ReplacingAnActivity.png differ diff --git a/docs/html/images/activity_task_design/ReusingAnActivity1.png b/docs/html/images/activity_task_design/ReusingAnActivity1.png new file mode 100644 index 000000000000..01c1729bcbc8 Binary files /dev/null and b/docs/html/images/activity_task_design/ReusingAnActivity1.png differ diff --git a/docs/html/images/activity_task_design/ReusingAnActivity2.png b/docs/html/images/activity_task_design/ReusingAnActivity2.png new file mode 100644 index 000000000000..288d2da757d0 Binary files /dev/null and b/docs/html/images/activity_task_design/ReusingAnActivity2.png differ -- cgit v1.2.3-59-g8ed1b