Wednesday, October 28, 2009

Android 2.0 platform release

Hi Readers,

Today Google released Android 2.0 platform for mobile devices, it bundled with many new features for user and developers and also there are few changes in the Android framework API. It can be deployable to Android-powered handsets by November 2009.

Android 2.0 Platform Highlights
  1. Now user can  add multiple accounts to device for email and contact synchronization, including Exchange accounts (Depends upon the Handset manufacturers). Combined inbox to browse email from multiple accounts in one page.
  2. Developers can create sync adapters that provide two way synchronization with any backend.
  3. Quick contact API provides instant support for communication with contacts. For eg. selecting the contact photo and you will get the list of all the available way of communication. This feature is also available in SMS, Email and Calendar.
  4. Search functionality for all saved SMS and MMS messages and also support auto delete features for oldest messages when a defined limit is reached.
  5. Camera API also include some new features like color effect, scene mode, flash mode, focus mode, white balance, rotation.
  6. Improved virtual keyboard support which include better keyboard layout to hit the correct character and improved typing speed with featured multi touch support. Better support for dictionary which includes contact names as suggestions.
  7. Better UI support for browser to provide instant search. Facilitate user to bookmark the web page with thumbnail. Also include support for HTML5 features and double tap zoom.
  8. Provide additional features for end users like infinite scrolling for event's agenda, event indicates the status for each invitee and also provide support for send invitation for new guests to events.
  9. Improved Media framework API for better performance and better hardware support. ASAP user put images in the media store, Thumbnail API will generate the thumbnail and also provide support for on demand retrieve.
  10. Improved Bluetooth API (2.1), which include support for Object Push Profile (OPP) and Phone Book Access Profile (PBAP) also developer can easily turn on and off bluetooth with in the application.
  11. KeyEvent has new key dispatching APIs, to help implement action-on-up and long press behavior, as well a new mechanism to cancel key presses (for virtual keys).
  12. Provide good support for different screen sizes and one binary/executable can run on different screen sizes.
If you are the developer then you can download Android 2.0 platform as component for the Android SDK. The downloadable platform includes a fully compliant Android library and system image, as well as a set of emulator skins, sample applications, and more. The downloadable platform is fully compliant and includes no external libraries.

Adding and updating the platform is very easy. I assume that you are using Eclipse with Android 1.6 SDK which include the AVD Manager and also helps you to install new SDK components. Before updating the platform It's mandatory to update the ADT(Android Development Tool) plugin for Eclipse. After that you launch AVD manager (Window >Android SDK and AVD Manager) and search for available packages and download all the required platform; which include the APIs, documentation and SDK tools for particular Android platform. Now while creating the AVD(Android Virtual Device) you can select the particular platform(1.1, 1.5, 1.6, & 2.0). That's it now you are ready to create the application for any platform.

I hope this post will give you some understanding of Android 2.0 platform. For detail information you can directly visit Android Developer Site.

Saturday, October 17, 2009

Happy Diwali

Hi Readers,

Wishing you all my friends, readers and their friends and their friends...... very very very happy, prosperous and lovable DIWALI...... God Bless You All........ Enjoy :)



Wednesday, October 7, 2009

J2ME Polish - Development Framework

Hi Readers,

I hope that my previous post help you some how. Please let me know if you want some more updates or article on any specific area. Today I am going to discuss about J2ME Polish Framework. What is the requirement for development frameworks? Features of J2ME Polish etc. So let's start:-

Why we need development frameworks?
To answer this question I am going to share one small example that will help you to have better understanding. We'll create a small app which has login functionality. First I am going to use only Java ME classes without any framework. Let's see:-
We have two options two create this app, one is by using High Level APIs and other is Low Level APIsHigh Level APIs have pre-defined classes defined. You need to implement the functionality and you need not to worry about coding any graphics yourself and the application looks like (at least to some degree) native application. However there is limited control of the UI and the UI will look different on different devices.
Low level API requires you to implement everything (how the keys work, how the different UI are drawn on the screen, etc). You have full control of the UI and the app looks the same on all devices (but usually different from the natve application on that phone).
We are going to use High Level APIs in this example. The app code look like this.

/**
  * Called at the start of MIDlet application
  */
protected void startApp() throws MIDletStateChangeException {
    midletDisplay = Display.getDisplay(this);
    ashnaForm = new Form("Ashna MIDlet");
    ashnaForm.append("Please enter your login credentials!");
    ashnaForm.append(userIDTxt);
    ashnaForm.append(pwdTxt);
    ashnaForm.addCommand(exitCommand);
    ashnaForm.addCommand(loginCommand);
    ashnaForm.setCommandListener(this);
    midletDisplay.setCurrent(ashnaForm);
}

/**
  * Called at the exit of MIDlet application
  */
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
    if (! unconditional) {
        throw new MIDletStateChangeException();
    }
}

/**
  * Used to handle the commands.
  */
if (command == exitCommand) {
    try {
        destroyApp(false);                
    } catch (MIDletStateChangeException ex) {
        Alert exitAlert = new Alert("Alert", "Do you really want to exit?", null, AlertType.INFO);
        exitAlert.addCommand(yesCommand);
        exitAlert.addCommand(noCommand);
        exitAlert.setCommandListener(this);
        midletDisplay.setCurrent(exitAlert);                
    }            
}

Now, let's see the output for this:-



You can notice that, UI for this app is not that much attractive. To make attractive UI we have so many options such as:-
  1. Use J2ME Low Level APIs
  2. Use different UI frameworks:-
    • J2ME Polish
    • LWUIT
    • Mobile Distillery’s Celsius
I am using J2ME Polish framework in this article. So before start coding we need to understand J2ME Polish first.

J2ME Polish:-
  1. J2ME Polish combines the power of Java Mobile (J2ME) with web-designing tool CSS.
  2. Separate the application UI designing from the application’s source code.
  3. Develop GUI using High Level APIs like Form, List, TextField etc.
  4. Provide additional J2ME Polish Custom Components like TabbedForm, TreeItem and soon.
  5. Add #style directives to applications source code for connecting code with the design.
  6. We can design and customize application using simple CSS text files.
  7. Configure additional GUI options in build.xml script.
J2ME Polish Architecture:-
J2ME Polish architecture based upon three main components, which are:-
  • Device Database
  • Build Framework
  • Client APIs
Device Database is the foundation of J2ME Polish and defined as device.xml. It includes the detailed information for J2ME capable devices – APIs support, Screen resolution, known issues, etc. It is used by build framework and client API to generate the executable for particular device.
Build Framework automate the necessary steps and based on the Ant tool. We can easily integrate it with IDE. The main advantage is that, it's extensible.
Client API has support for great GUI using CSS. It provide support for advance GUI classes such as, Tabbed Form, Tree Item, FilterList etc. In addition to this, it also support animation effects such as, text and screen transition effects.

For every device, the approach followed by J2ME Polish:-

Now I am going to use same example code that I used earlier, but with few additional changes. We have to create a file with name polish.css in the resource folder and need to define all the styles. After that we'll use same styles with pre-processing statements in our code. I'll show you with example:-

/***Style entries in polish.css file***/
titleBackground {
    color: #5F0000;   
}

basicBackground {
   color: #9C0000;
}

menuBackground {
   type: round-rect;
   color: #5f0000;
   border-width: 2;
   border-color: #5f0000;
}


title {
    padding: 2;
    background: titleBackground;
    font-style: bold;
    font-size: medium;
    font-face: system;
    font-color: #ffffff;
    layout: center | expand;
}

menu {
    menubar-color: #5f0000;
    background: menuBackground;
    min-width: 100;
    padding: 1;
    //#if polish.MenuBar.Position != right && polish.MenuBar.Position != invisible
    view-type: slide-up;
    //#endif
    font-style: bold;
    font-size: medium;
    font-face: system;
    font-color: rgb(255, 255, 255);
    layout: left;
    focused-style: menu:hover;


Here I defined few styles, but in same way you can define as per your requirement. Now we'll see how we can use these defined styles in our app and now code look like this:-

/**
  * Called at the start of MIDlet application
  */
protected void startApp() throws MIDletStateChangeException {
        midletDisplay = Display.getDisplay(this);
        //#style form
        ashnaForm = new Form("Ashna");
        //#style headingLabel
        ashnaForm.append("Please enter your login credentials!");
        //#style txtField
         ashnaForm.append(userIDTxt);
        //#style txtField
         ashnaForm.append(pwdTxt);
        //#style loginButton
        ashnaForm.append(loginBtn);
        loginBtn.setDefaultCommand(pressCommand);
        loginBtn.setItemCommandListener(this);
        ashnaForm.addCommand(exitCommand);

        ashnaForm.addCommand(loginCommand);
        ashnaForm.setCommandListener(this);
        midletDisplay.setCurrent(ashnaForm);
 }



/**
  * Used to handle the commands.
  */
if (command == exitCommand) {
    try {
        destroyApp(false);                
    } catch (MIDletStateChangeException ex) {
         //#style infoAlert
        Alert exitAlert = new Alert("Alert", "Do you really want to exit?", null, AlertType.INFO);
        exitAlert.addCommand(yesCommand);
        exitAlert.addCommand(noCommand);
        exitAlert.setCommandListener(this);
        midletDisplay.setCurrent(exitAlert);                
    }            
}

Check the text in blue color in above sample code, in this way you can use pre-defined styles in your app. Now check the output for this app.



So now you can see the difference between the GUI for same app. Same GUI effect we can provide using Low Level APIs also, but over there it's time consuming and for each device we need to port our application. Using J2ME polish you need to just code once and define all the styles after that build framework help you with the device fragmentation.

I hope this article gives you some understanding about J2ME Polish framework. If you have any queries, Please let me know. I'll try my best to answer your queries.