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.

• Launch your main activity from an icon at Home - If your application can run standalone, it should probably be started by the user touching an icon in application launcher (typically implemented as a sliding drawer on the Home screen), or from a shortcut icon on the Home screen, or from the task switcher. (The mechanism for this is for the activity to have an intent filterwith action MAIN and category LAUNCHER.)

• Launch your activity from within another application - Perhaps your activities are meant for re-use. For example, many applications have data they want to share with other users. Activities that can share data with other users include email, text messaging and uploading to a public website.

If one or more of your activities can be an alternative to an existing activity in another application, you can make it available to users at the point they request that activity. For example, if your activity can send data to others (such as by email, text messaging, or uploading), consider setting up that activity to appear as a choice to the user. To give a specific example, Gallery enables a user to view and share pictures. When the user chooses "Share" from the menus, the system compares the "Share" request (an Intent object) to available activities (by looking at their intent filters) and displays choices to share. In this case, it matches Email, Gmail, Messaging and Picassa. If your activity can send a picture or upload it to a website, all it needs to do is make itself available for sharing (by setting its intent filter).

Another activity can start your activity either with or without expecting a result back.

o Start an activity expecting a result - This approach is closed loop, where the activity being started must either return a valid result or be canceled. In the previous examples of sharing a photo from a Gallery, the user ends up back in the Gallery after completing the send or upload procedure. These are examples of starting an activity external to the Gallery. (Such an activity is started with startActivityForResultQ.)

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

0 0

Post a comment