I was thinking about the main components that provide the building blocks for your Android application, and on how they relate to similar concepts from the Java Micro Edition (Java ME) platform:
Activity. Activities in Android are the presentation layer for the application you are building. For each screen you have, their will be a matching Activity. Similar to this concept, in Java ME you have Forms (and more general maybe Screens). An Activity uses Views to build the user interface; similarly, a Form uses different items such as text fields, data fields, choice groups, etc. Generally speaking, in Java ME, on a Screen (or on a displayable), you can place a Canvas, an Alert, a List, a TextBox, and finally a Form. All these elements are used to build the graphical user interface for displaying information to the user and interacting with him by responding to the user actions.
Services. Services are those components that run in the background, and which do not interact with the user. They can update your data sources and Activities, and trigger specific notifications. I tried to think of a similar component in Java ME, but could not come with one. The only concepts I could think of was Threads and Timers (a way for threads to schedule tasks for execution in a background thread). The concept of Threads exists separately in Android also, hence such a comparison is not quite precise. Until background MIDlets are available with the upcoming of MIDP 3, I guess we do not have any other options.
Content Providers. They encapsulate data and provide it to your application, therefor acting as interfaces to the application databases. Sharing data across applications is achieved also by means of Content Providers. Such a concept is related to the RecordStores in Java ME, and more general, to the Record Management System (RMS - the persistent storage mechanism in Java ME).
Intents. Intents are a way of specifying what intentions you have in terms of a specific action being performed. Intents are mostly used for launching Activities. A similar concept in Java ME is described in the Broadcast Receivers section.
Broadcast Receivers. These components listen for broadcast Intents that match some defined filter criteria, and can automatically start your application as a response to an intent. Looking closely at the Intents and Broadcast Receivers components, for me, PushRegistry comes into mind. A PushRegistry is used to request a wakeup call from the implementation. What is important to understand about PushRegistry is the fact that they have a lifetime beyond that of a MIDlet. It is part of the MIDlet management software that runs on the device. When your MIDlet registers (at runtime or at install time) for push notifications, the device is obligated to listen incoming network connections and start your MIDlet if the appropriate connection has been made.
Notifications. Notifications let you signal the user by alerting him of an incoming event, and without using a separate Activity to achieve that. For example, you are monitoring the weather, and you want to be notified when a hurricane warning is in effect for your area (common in South Florida where I leave). This can be accomplished by adding Notifications to your weather monitoring system. In Java ME, one similarity would be the use of Alerts that inform the user about different events.
In later posts, I will describe more similarities between the two platforms at different levels. Stay tuned!
No comments:
Post a Comment