To work with Android application development, we need to know a few basic things. Here, a brief discussion on those concepts will be provided as well as links to presentations discussing those topics in details.
Activities
More-or-less, anything we see on the screen of an android device and interact with it may be called an activity. For example, in the following figure, each of the screens is an activity.
Intents
An intent is simply an action optionally bundled with data on which the action is to be performed. As an example, consider the figure above. When a user taps on a list item, the details of the list item is shown. However, there are many list items and clicking any of those will result in the same details view, but with different data, depending on the tapped list item. So, when starting the details activity, we need to know which list item has been clicked by the user. This data along with the activity name that we want to start, is bundled into an intent and then a new activity creation request is placed.
Intents are not merely for starting activities. To know other functionalities of intents, see the presentation Android Insights - 1: Intents.
Services
Whereas an activity is any operation that is visible to the user, a service is any operation that is hidden from the user, run in the background. For example, you may set an alarm to go off at a certain time. This service is referred to as the Alarm Service. A service may start an activity, however. For example, the alarm service may present a view to the user so that he may stop or snooze the alarm.
Usually, services are background services. The user doesn't need to be aware of such a service being run. Whenever the android system needs memory, it may kill the service while it's running. However, there may be services that the user is actively aware of and he won't be happy if the service is killed while running. For example, a user may start playing a song and move from the player to another application and work therein. The song will continue to play in the background as a service. However, killing the background song when in short of memory will displease the user. In this case, the developer of the background service needs to notify the android system that it shouldn't kill such a service. Identifying the service as foreground rather than background is the trick for it. Details about setting a service as foreground as well as in-depth discussion on services in general can be found in the presentation Android Insights - 2: Services.
Content Providers
Suppose you're fed up with the built-in Contacts application and plan on developing a rock-and-roll Contacts application. You'll need to get access to the contacts in the user's phone. But how would you request for the stored contact details and more importantly, to whom in the android system? Content Providers solve the problem. A content provider provides content (which can be anything - any information) through some well-defined interfaces. It's implemented in such a way so that users of the content provider can code as if they were accessing records from a database. Again, you can also use a content provider to provide access to your application's internal data through interfaces defined by you.
To know more about content providers, follow Android Insights - 3: Content Providers.

No comments:
Post a Comment