Showing posts with label Mobile app. Show all posts
Showing posts with label Mobile app. Show all posts

Thursday, July 9, 2009

APIs in J2ME

General APIs
The core APIs are defined by the underlying Connected Limited Device Configuration.

javax.microedition.io

Contains the Java ME-specific classes used for I/O operations.

javax.microedition.lcdui

Contains the Java ME-specific classes used for the GUI. LCDUI has a simple screen based approach where a single Displayable is always active at a time in the application user interface. LCDUI API provides a small set of displayables common in mobile device user interfaces: List, Alert, TextBox, Form and Canvas. For all displayables the device MIDP implementation has control over the presentation and layout of the displayable. Canvas is a low-level graphics surface for which an application has full control over what is rendered to it, although normally some space is reserved for system areas like screen title and indicators common in mobile device UIs. Since MIDP 2.0, Canvas also supports a full-screen mode that allows to make full screen graphics, which is especially useful for games.
LCDUI also has quite unique approach of abstract operations, called Commands. The placement of commands added to a displayable is completely up to the device implementation of this toolkit. The application programmer uses API specified command types to indicate the usage or purpose of the command in application user interface. Common types are BACK, EXIT, ITEM, SCREEN. The idea of the command abstraction is to make applications more portable between various different mobile device. Application developers should use the command types properly to indicate the purpose of an operation, and device implementation then places the operation to the common location for a given type in device's specific user interface style. This may be e.g. a specific key, like "a back navigation key" for BACK commands or button on screen.
The term LCDUI was actually a joke in JCP Expert Group that created it. It has not been opened up in the MIDP specifications but stands for Limited Capability Device User Interface. The joke was that no-one else really knows what it stands for. Then later the Programming Wireless Devices with the Java 2 Platform, Micro Edition book gave this term out.
Other common definitions have appeared. "Liquid Crystal Display User Interface" would reflect the fact that mobile phones normally use LCD displays; however, the API is not specifically tailored to this particular display technology. It is also said that "LCD UI" stands for "lowest common denominator" due to the fact the specific UI has simplest possible design.

javax.microedition.rms

Provides a form of persistent storage for Java ME. It's like a database for the mobile device.
"Record Store"(class) is used to store the Data: RecordEnumeration(Interface) , RecordComparator(Interface), RecordFilter(Interface), are used to apply user queries for sorting,filtering the data of all the data present; and comparison of contents of two or more RecordStores is done by these Interfaces.Data is stored and must be retrieved from the RecordStore using a ByteArray.(i.e; data is stored in Bytes(string.getBytes() and stored in ByteArray Byte a[])

javax.microedition.midlet

Contains the base classes for Java ME applications.

Specialized APIs added in MIDP 2.0

MIDP 2.0 saw the introduction of gaming and multimedia APIs and some optional packages.

javax.microedition.media

Contains the base classes of the multimedia playback. These are approximately a subset of the JSR 135 Java Mobile Media API.

javax.microedition.lcdui.game

A gaming API aimed at simple 2D sprite based games.

javax.microedition.pki

Authenticate APIs for secure connections.

Optional JSRs

The following JSRs are not part of MIDP (1.0 or 2.0) but provide extra functionalities on some handsets. However, there is no guarantee that a MIDP2.0 handset implement such APIs

javax.microedition.messaging

Wireless messaging API (optional), for sending SMS and MMS messages.

javax.microedition.pim

Personal information management API (optional), access the device's Address Book , to-do List, Calendar.

javax.microedition.io.file

The File Connection Optional Package (FCOP) is one of two optional packages defined by JSR 75 through the Java Community Process. The FileConnection API specified in JSR 75 gives access to the local file systems on devices like PDA. In order to overcome security issues MIDlet needs to include requested file permission in its JAD file under MIDLet-Permission property.

Development Tools

There are several different ways to create MIDP applications: Code can be written in a plain text editor, or you can use a more advanced IDE such as NetBeans, IntelliJ (with bundled Java ME plugin), or Eclipse (with plugins such as EclipseME) which has a user interface for graphically laying out any forms you create, as well as providing many other advanced features not available in a simple text editor.

Noteworthy Limitations of MIDP 1.0

  • MIDP 1.0 has no active rendering APIs
  • MIDP 1.0 has no support for direct access to image pixels (RGB data)
  • MIDP 1.0 has no support for full screen mode
  • MIDP 1.0 has no support for audio
  • MIDP 1.0 requires only HTTP support
  • MIDP 1.0 cannot query key status (although key events are supported)
  • The specifications are not always clear, leading to differences in implementations
  • Some limitations may be avoided by using a vendor-specific API or MIDP 2.0, which obviously reduces the portability of the application

Thursday, June 11, 2009

Android Application Lifecycle

In Android, the applications are run as a separate Linux process. So the application lifecycle is closely related to the process lifecycle. The application process lifecycle is handled by the system depending on the current system memory state.
In case of low memory, the Android system kills some less important process. The process importance is decided depending on the state of the process components.
The process types depending on the importance are as follows (from most important to least important):
1. Foreground process: A foreground process is the application process with which the user is currently interacting. The process is considered to be foreground if its Activity is at the top of the Activity stack (its onResume() has been called) or BroadcastReceiver is currently running (onReceive() method is currently getting executed) or its Service is executing callback functions like onCreate(), onStart() or onDestroy() methods.
2. Visible Process: A visible process is the process which has an Activity visible to the user (its onPause() method has been called).
3. Service Process: Service process contains a Service for which startService method is called and the service is running.
4. Background Process: The background process does not have any visible activities to the user. (Activity onStop() method has been called).
5. Empty Process: Empty process is the one that does not have any active application components. These processes are kept on for caching purpose.
It is important that application developers understand lifecycle of the application process. Not using these correctly can result in the system killing the application’s process while it is doing important work.