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!");

  * 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 {
    } catch (MIDletStateChangeException ex) {
        Alert exitAlert = new Alert("Alert", "Do you really want to exit?", null, AlertType.INFO);

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;
    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
        //#style txtField
        //#style loginButton


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

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.

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, 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,


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) {

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) {

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


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-;

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();

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 ="/res/loginTheme.res");
    UIManager.getInstance().setThemeProps(res.getTheme("Test Theme"));
} catch ( ioe) {


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.

Monday, August 17, 2009

What I really want from my life

Everyday I wake up at my room in morning and think is this the place where I really want to be? Sometimes I feel yes but most of the time I got answer no. Everyday I ask this question to myself. It's all about finding myself, and having the courage to admit certain things to myself, do things that scare me, and know that I'm doing the right things even when others question me.

We all are part of such society where others already decided our future. My son will do this in future, my brother will do this in future or my husband will do this... bla bla.... What the @#$#$%. I don't want to be like others; I want to be ASHISH and I took different path in my life; Initially I faced some difficulties but I overcome these and now I am working with one of good firm and drawing handsome salary and feel little bit happy where I am. But still there is some thing that is missing from my life. I don't know what. I am really confused these days.

Sometimes I thought in our society our target is already defined just like the interface where all the methods signature is defined and need to implement by ourself in our life class. I took this example because I am a programmer, I apologies who didn't like this.

Being a child we need to study hard and get some good percentage, after that being a young guy we need to finish our degree and get some good job earn money and this race for money continues till we die. I agree we require money for good life but in this race we forgot how to live a happy life? Do we really happy with our life.... I don't know about others, but I don't and something is there that is still not part of my life... I am still running for that and even I don't know what is that... I hope some day I'll get the answer...

I hope :)

Sunday, March 15, 2009

Application Version Upgrade in MIDP 2.0 and MIDP 1.0

Hey Readers,

First of all very nice good evening to all of you. I really appreciate your love and interest and special thanks to Rochak sir, who believe in my posts. If there is any mistake in my posts then please guide me; I am trying to share my knowledge with all of my readers and this will continue in future.

Today I am going to share version upgrade for mobile application using J2ME in MIDP 2.0 and MIDP 1.0. Being a developer & entrepreneur you always want how to inform user about the application's version upgrade. Because you don't want to loose your customer and want to facilitate user by application's new features. The solution is as follows:-

As a developer or even as a user, I always wish that if there is any version upgrade then please let me know at the startup of application even before Splash Screen appears. You can implement the version upgrade functionality in startApp() method. Even you can also store current version in the RMS. Take a look at the functionality:-

protected void startApp() throws MIDletStateChangeException {
try {

/**Check the record store for available version.*/

//fetch the latest available version from server and compare with stored version in RMS

if (!versionStored.equals(availableVersion) && optionalUpgrade) {

} else if (!versionStored.equals(availableVersion) && mandatoryUpgrade) {

} else if(versionStored.equals(availableVersion)) {

catch(RecordStoreException rse) {
//If application is fresh installation then at startup you'll receive the RecordStoreException, because no record store available.

/** Open record store and store current version of MIDlet. */


Now you are thinking what is the purpose of optionalApplicationUpgrade() and mandatoryApplicationUpgrade(); Both of these functions are very useful. Consider a scenario in which you update only the themes for application but it is not mandatory update because there is no functionality upgrade, in this scenario you can use optionalApplicationUpgrade() and ask user to allow upgrade. But user can may be skip this upgrade; whereas in functionality upgrade you can use mandatoryApplicationUpgrade() and user can't skip this upgrade.

Till now we setup all the basic architecture for application upgrade, but how we are going to upgrade this is the basic query in your mind. Let's resolve that:-

protected void updateApplication() {

if (profile == MIDP2.0) {

String applicationUpdateURL =;


/** Store the updated version of application in RMS */

} else if(profile == MIDP1.0) {

/** Display information to the user for manually upgrade application or you can also send information to the application server to send a WAP push message. */



Using updateApplication() method you can handle functionality for both MIDP1.0 and MIDP2.0, because platformRequest() method is not supported in MIDP1.0; so either you display the information to user or you can push the wap push message to user by sending a specific format message to the OTA server.

This is all about J2ME application upgrade, If I miss something or you have any doubt then please let me know. I'll try my best to explain each of your queries.

Saturday, March 7, 2009

J2ME & Unit Testing

Hi Friends,

As you came to know from the blog title that today we are going to discuss about unit testing approach for J2ME. Before moving further, let's first understand unit testing. Most of the Mobile Application developer think that unit testing is same as the functionality testing which is not true. Functionality testing comes in picture when application installed on mobile and then we test the proper functionality of the application as per the product specification; where as unit testing comes in picture at your code level. In simple words, Unit Testing is an approach that provides confidence to the developer that given piece of code written by him/her are fit for use.

To support unit testing in JAVA we have JUnit Framework, we cannot use same framework for J2ME because JUnit rely on Java Reflection API whereas reflection API is not part of J2ME environment. So there is refine version of JUnit for mobile application unit testing. Actually there are two:
a) J2MEUnit
b) JMUnit
Both are Open Source and used for unit testing approach, but JMUnit has better approach for same. JMUnit has rich set of assert methods as compared to J2MEUnit. In future there are planning to merge these two frameworks into one & emerging framework will have the features of both.

My Experience with JMUnit:-
I used JMUnit in our project and trying to share my experience with all of you. You can use ANT task for running your unit tests. The basic approach for unit testing is that write test cases for those classes which internally call other class's methods, so that you need not to write test cases twice. For example, You can write test cases for one class that manage all the UI related functionality, second that manage RMS related functionality, third that manages data objects, fourth that manage HTTP/HTTPS connections, and the last one is your request and response objects. Suppose you have some abc() method in any class then you should write your testclass with method name testAbc() and test your code scenario as per the requirement. The basic architecture of test class is as follows:

First you have two import JMUnit APIs according to the CLDC
i) jmunit.framework.cldc10.*; //or
ii) jmunit.framework.cldc11.*;

Now basic skelton of a class--

public class Xyz extends Testcase {
public Xyz() {
super(int totalTests, String xyzTest);
public void setUp() {
// define any object or any initialization as per your requirement.
public tearDown() {
// release memory.
public void testAbc() {
// write your test case
public void test(int testNumber) throws Throwable {
switch(testNumber) {
case 0:
When you write all the test cases for your defined classes then you can combine them to in a TestSuite class so that each test will run using your ant script. The architecture for TestSuite class is as follows:

public class AbcTestSuite extends TestSuite {
public AbcTestSuite() {
super("Test Suite");
add(new Xyz);
add(new .......);
Now in the ant script you have to map the JMUnit jar files and you can also specify your test classes, source and reports directory path so that each will move to there respective folder and at the end html based reports will get generated.

1) I am not able to test the RMS value.
2) Also not able to test the UI Classes screen transition.
As per their documentation, I am able to run emulator from ant script but still not able to test both of them. If someone earlier also faced this problem and got any solution.... Please let me know.

I tried to share all the facts related to mobile application testing using JMUnit. If I forgot something please update me with your comments.

Wednesday, February 4, 2009

MVC, Design Patterns, J2ME, Optimization

Dear All,

Welcome again....

Today I have some specific things to share with all of you... As you all came to know from the title of this article that we are going to discuss MVC approach in J2ME. Earlier I used modular approach to develop mobile application, but now I am exploring more on MVC approach in J2ME and I came to know it is really helpful to develop the secure and modular application. Some of you are well aware of this approach and mostly used in your projects. But some of you may be yet not used such kind of approach in your projects then this article may help all of you. I'll try my best to make you understand this approach using J2ME.

For example suppose we have simple application in which user can login and after login user can access some kind of information. Then first of all we can design our application in such a way that data of one class will not exposed to other classes. Suppose all of UI classes will have access using one single class, I name it UIController you can name it as per your requirement. Now all other classes like ModelFacade, & ConnectionManager will interact to LoginUI using UIController and no method of RMS and ConnectionManager will exposed to LoginUI. UIController have one method named it as showLoginUI(), which will take care to display Login screen for application.

Whereas ModelFacade is a class that have single point contact between RMS Class and other classes, so that no stored data will exposed to other classes (Other classes don't have any idea about the content). In same manner ConnectionManager class will manage only HTTP and HTTPS connections and will have logic to connect with server.

Only methods have public access in any class and if you want to use any variable in any other class, then use getter/setter method for that variable.

If you design your application in such a way then there is no security loophole. Try to follow this approach, it really helps you while developing application and also help you in real time testing.

To optimize your application you must follow the Java coding standards, also don't create too much objects because they will cause memory loss. If reference is already present then use that don't create new. For eg. 

If ( exampleObj == null ) {
else {
//do something..

If you are using images in your application then used well optimized images.. consult with graphics team. Avoid multi - dimensional arrays in J2ME. Always use pre - computing. Avoid for loop statements if possible, use switch cases and if statements or you may use only those statement in loop which require repeated execution(for loop tightening). 

As we know that Java handle garbage collection itself, but while exception occurred and screen transition is there then call System.gc() explicitly. It'll also help you to reduce memory usage by application.

I hope this article will help you. If you have any suggestions and comments please let me know.

Now time to log off, will meet you with some other topic.

Saturday, January 31, 2009


Dear all,

Welcome to our blog... 

Right now may be some thoughts are going on in your mind. May be you are thinking that, in this blogging era same another blog addict is publishing few lines. But I have a reason for this, actually I want to share my thoughts with all of you... of-course I can share same with you using mail etc. but as you all know how seriously we read mails... plus the major reason to publish a blog is to get reactions from best critics all over the world. Such type of debates will increase our knowledge and may be change our preception towards some situations and scenearios. 

Thats why I used this space for sharing my knowledge, thoughts, latest technical trends, latest innovations etc. In addition to technical things one of my close friend will also share latest designing trends, her preception towards sketching, painting, graphics etc... 

We both have humble request to all of you to post your comments.... So that we will increase our knowledge base.

Thanks for your patience...

Now time for log off will meet you soon....