Wednesday, September 23, 2009

Android 1.6 Platform - "Donut"

Hi Readers,

Welcome again and today we will discuss about Android 1.6 SDK. The Android developer team has announced the release of the Android 1.6 SDK on 15 Sep 2009, with the biggest news from the release support for different screen sizes, CDMA based networks. Donut is update with new battery usage feature which gives you the information of battery consumption by any application. Also there is update for camera application. We are going to discuss these features in detail now:-
  1. Search Feature:- Android 1.6 comes up with redesigned search feature, which helps user to search quickly, efficiently and consistently across multiple applications (Contacts, Browser, and the web) directly from home screen. The system constantly learns which search result is more relevant based on what is clicked. So popular relevant contacts or apps which are previously used will bubble up to the top when user types the first few letters of a query. The search framework also provides developers a way to easily expose relevant content from their applications in Quick Search Box.



  2. Update for Camera:- Android 1.6 also got the update for camera app also, now user can switch between still and video capture mode using one click easily. Other enhancement is faster load time when launching the camera app; Android team is claiming that the app will launch 39% faster and will also shave off 28% of the time needed between taking the pictures, which really help the end users. Now user has option to select multiple photos for deletion.
  3. Battery usage indicator:- The feature I admire most is battery usage indicator. Using this app end user has all the information about battery consumption by each app, user can take action to save the battery life by adjusting settings, stopping app or even uninstall the app. You can pull up this app anytime available under settings or you can click on little button that popped up when the device tells you that you have 15% battery life remaining.
  4. Android Market Update:- Android Market also got update interms of some features which are listed below:-
    1. At the Home Screen, user can choose among Apps, Games and Downloads.
    2. Inside the category, we have options to explore apps with in Top paid, Top free and Just in.
    3. User can also see some screenshot for application along with other user's reviews.
  5. Text-to-speech engine:- Android 1.6 include multi-lingual speech synthesis engine called Pico, which allows any Android app to speak a string of text with an accent that matches the language. Language supported by engine: English (American and British accents), French, Italian, German and Spanish.
  6. Screen Resolution:- Android 1.6 enables application to be rendered properly on different display resolution screens. Developers can also specify the screens supported by the application. Developer need to mark an entry in Android Manifest file with . If your application is run on a device whose screen size is not defined in the element, the system displays the application in compatibility mode, which performs best-fit match for screen resolution.
  7. Accessibility framework:- With this framework, developers can create accessibility plugins that respond to user input, such as making a sound when a new window is shown, vibrating when navigating to the top of a list, and providing spoken feedback.
    1. android.accessibility package that includes classes for capturing accessibility events and forwarding them to an AccessibilityService handler.
    2. AccessibilityService package that lets your application track user events and provide visual, audible, or haptic feedback to the user.
  8. Linux Kernel Upgrade:- Android 1.6 includes the Linux kernel upgrades from 2.6.27 to 2.6.29.
You can download Android SDK 1.6 from Android Developer Site. But you need to give attention while installing Android 1.6 SDK, because there is also update available for ADT plug-in from 0.9.1 to 0.9.3. After that while upgrading your existing project open project and right click on project go to Properties, select the build target Android 1.6. Now open AndroidManifest.xml file and update the value of minSdkVersion from 3 to 4. Now all are set you just need to create Android Virtual Device (AVD) and run your project.

Monday, September 14, 2009

Motorola's first Android handset - CLIQ


After long time Motorola comes with new Android handset named "Motorola CLIQ" at Mobilize 2009. Frankly speaking I am really waiting for Motorola's new device. First look of Motorola device is really impressive. Now one question is coming in your minds what is more special about it, there are already 4 to 5 handset present in market. So, readers it has something special in it; to find what is that we just explore this handset. The specific feature which makes Motorola CLIQ different from other Android handset is "MOTOBLUR". Customized home screens are the latest trend and widely used in various devices, so Motorola come with custom Android UI.
Motorola's MOTOBLUR is not just an Android screen/theme, but an integrated service that pushes updates from almost all social networks straight to device's home screen. Some of the following features which we'll also see in upcoming Motorola's devices.
  1. As I mentioned earlier social networking feature to the device screen. If you are very social person and use social networking apps frequently then MOTOBLUR is for you. You need to enter account information at the time of initial device setup and then enjoy need not to enter login credentials again. In addition to this, all social networking apps directly access device's core features.
  2. Motorola develop so many widgets to home screen for social networks, RSS feeds and messages directly on the device's home screen. For example some feature widgets are Facebook, Twitter, Myspace, RSS feeds for sports, weather and entertainment etc. Point of attraction is contact and dialer application shortcuts.
  3. Till now Android gives you the feature to sync your contacts with Gmail account, but Motorola take you one step ahead and provide a feature to sync your account with all the social networks. Each contact sync with latest pic, status update, contact info etc. The add-on feature is that you are able to see all the info on incoming call from that contact.
  4. Universal message inbox that will collect message from contacts, email, message from Twitter, notes from Facebook and Myspace. User has facility to filter and view them all at once. Motorola got advantage by delivering it first as compared to Google's Wave service.
  5. Now you can update your status to all of your social networks with one click and publish your status update to all at once.
  6. The best thing about this device is safety and security feature. Suppose if you lost your phone then you can remotely wipe data and  restore that data to device with MOTOBLUR feature free of cost, whereas in Apple iPhone you need to subscribe to MobileMe for year which cost 99$. 
  7. It provides you a feature to share your images on the go. You can capture a image and upload it directly to the social networks and also add a caption to it. Each image is automatically sized and formatted according to the service you use.
I appreciate and congrats Motorola for building a good device with good features. The technical specification of device is here:-

Monday, September 7, 2009

Lightweight User Interface Toolkit (LWUIT) API and J2ME

Hi All,

Today I am going to discuss with you LWUIT UI API. Lightweight User Interface Toolkit (LWUIT) is basically a UI library for JAVA ME Platform. It helps developer to create visually attractive or rich interfaces for mobile applications and compatible with MIDP 2.0 and CLDC 1.1 devices. It provides Swing like functionality but without the tremendous power and complexity of Swing. LWUIT offers a basic set of components, layouts, themes and animated screen transitions. The hierarchy for these UI classes is as follows:-
The architecture of LWUIT is inspired by Swing, it has some features that are not available in Swings like themes, animation and painters etc. Features like MVC, layout managers, render, and EDT(Event Dispatch Thread) are similar to Swing. The LWUIT layer is present on top of the JAVA platform, runs on the CLDC and works with LCDUI. LWUIT library uses native rendering engine of device and renders onto GameCanvas. To understand this, we need to go through from LWUITImplementation and Display class of LWUIT library; LWUITImplementation is the foundation abstract class and extends the javax.microedition.lcdui.game.GameCanvas, and defines number of critical function. Now you can understand that for LWUIT application LWUITImplementation is the starting point (which is basically an object of GameCanvas) and used to draw all the components. The Display class is that which manage the painting and event handling with LWUITImplementation as a partner. It's used to show forms and start the EDT. Before any form is shown, we must register the MIDlet, by calling static method Display.init(MIDlet myMIDlet).

Now you have dobout in your mind why we need to register MIDlet with Display class of LWUIT. The answer is very simple, the init method instantiates LWUITImplementation and invoke the init(MIDlet myMIDlet) method of LWUITImplementation and get the instance of javax.microedition.lcdui.Display class. Don't get confuse by two Display classes, we are going to use Display class of LWUIT API only for LWUIT application, because it internally call LCDUI Display class. To start you need to download LWUIT jar file. The link for downlaoding and LWUIT API documentation is :
I'll explain some components of LWUIT using small POC, so that you'll get good idea. First you need to create a project using any IDE and add LWUIT jar file to the project library, so that you are able to access LWUIT APIs.

Now create a Java class LoginMidlet and implement ActionListener interface so that every action event get handle for application.

public class LoginMidlet extends MIDlet implements ActionListener {

After that we need to register our MIDlet with LWUIT as I explain earlier,

Display.init(this);

We are going to use some components of LWUIT APIs like Container, TextArea, Label etc. We'll use LWUIT Form component and arrange all other component on it.

Form appForm = new Form("Login LWUIT Form");
appForm.setLayout(new BorderLayout());

Now we'll use Container to arrange all the other components. First we'll define the layout.

Container formContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));

Now we'll define each component one by one, Firstly Label and then I am using TextArea for input; you can also use TextField according to your requirement.

Label uName = new Label("Username");
TextArea uNameTxt = new TextArea(1, 10, TextArea.ANY);
uNameTxt.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent actEvnt) {                    
        if (null != appForm) {
            appForm.refreshTheme();
            appForm.show();
        } 
    }
});


Label pwdLbl = new Label("Password");
TextArea pwdTxt = new TextArea(1, 10, TextArea.PASSWORD);
pwdTxt.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent actEvnt) {
        if (null != appForm) {
            appForm.refreshTheme();
            appForm.show();
        }
    }
});

We defined the basic UI for our application now we need to arrange them and append to the Container.

formContainer.addComponent(uName);
formContainer.addComponent(uNameTxt);
formContainer.addComponent(pwdLbl);
formContainer.addComponent(pwdTxt);

After that we need to add this formContainer to appForm:-

appForm.addComponent(BorderLayout.CENTER, formContainer);

To display the current form on the screen, we'll use-

appForm.show();

Our basic POC is done and application will look like this.


Now you are thinking that why we used LWUIT, what is special about it. The main difference using LWUIT, is the Resources and UIManager section. LWUIT help us to provide good UI for application. There are two concept Styles and Themes. We use style for individual component customization means if we want to put some special customization for one label only. For e.g.

Label uName = new Label("Username");

Get the style object

Style styleObj = label.getStyle();
styleObj.setBorder(null);
styleObj.setBgTransparency(0);

Whereas, Themes are used to change the overall look and feel for application without programming. Themes are stored in resource files and loaded during runtime. We need to use this code in our application to laod a theme.

try {
    Resources res = Resources.open("/res/loginTheme.res");
    UIManager.getInstance().setThemeProps(res.getTheme("Test Theme"));
    
} catch (java.io.IOException ioe) {
    ioe.printStackTrace();

}

After using this theme our application looks like this:-


To create theme we use Resource editor. It is bundled with LWUIT library. You need to extract zip file and in util folder you'll find Resource Editor. The screenshot for Resource Editor is:-


LWUIT is in early stage but still it has really good support on devices. To browse the LWUIT Device Database, Please visit:

I hope this article help you to understand the basic architecture and features of LWUIT. Please let me know with your inputs.