Mobile Development

How to make a simple Android widget


MIDP 3.0 : Screen Saver and Auto Start MIDlets

Now you can make screen saver MIDlets. You can also set your MIDlets to be started during mobile start up.This is a surprising addition to the MIDP 3.0. Now you can create a MIDlet which will run when the device is idle for a specified amount of time.

To make a MIDlet into a screen saver MIDlet you will just need to add the following line in your JAD file or manifest file.

MIDlet-Category-1: screensaver

This line instructs the AMS(Application Management software) that the MIDlet is of category “screensaver”.

Screen Saver registration process

When Screen Saver MIDlet is installed following chronology of events happen

  • The AMS checks if any other screen saver is already registered.
  • If another screen saver is registered the user is prompted that there is already a screen saver configured and whether the user wants to change his screen saver.
  • If there is no screen saver then the user is prompted whether he wants to set a new screen saver.
  • In both the above cases screen saver is set only when the user agrees to it.
  • Finally after the screen saver is set the user is notified accordingly.

This screen saver functionality in MIDlets adds a new entertaining service to existing bouquet of MIDlet services. After this if the MIDP Expert Group asks me “What is your next wishlist?” I would say “Themes MIDlet

Auto Start MIDlets

MIDP 3.0 addresses the long requested functionality of auto start up of a MIDlet when the device is switched on. This functionality was already given by some device vendors. What the MIDP Expert group now brings to table a generic standard which has to be followed by all the vendors.

To make a MIDlet into a auto start up MIDlet you will just need to add the following line in your JAD file or manifest file.

MIDlet-Category-1: autostart

Get set to create your robotic MIDlet………………


J2ME JAR size optimization: Decrease your JAR’s size

J2ME devices have JAR File restrictions and this could vary from 32 KB to 200KB and over. Depending on the devices your application is ported to, JAR sizes have to be decreased, here are some of the tricks you can use for decreasing the JAR file sizes. Never start coding with optimization in mind. Only optimize at the fag end of the project after all code readability is also important. Intermediate device deployments can also be done to check the device compatibility and to get a fair idea of how your application works on the target devices.

Thumb rule for coding J2ME applications is modular programming approach. Never use design patterns when the target devices consist of low end devices. We may also think about two code bases one for high end devices with colorful images etc and another for low end devices with bare bone functionality.

  • Obfuscation is a technique used not only to protect make your source code unreadable but also comes with added advantage of smaller JAR file memory footprint. The most popular open source obfuscators are ProGuard and RetroGuard.
  • Reduce methods if possible. Condense multiple methods to a single method.
  • Reduce try-catch blocks to bare minimum.
  • Use lower versions of JDK while packaging JAR files, JAR File size created using JDK 1.3 is 5% to 20% lesser than those created with JDK1.4.
  • Remove redundant features. Some times you may have to sacrifice some of the essential features.
  • Split your application to multiple JAR files or services.
  • Reduce number of classes. See if some of the classes can be clubbed together into a single class.
  • Remove Array instantiations and use Strings instead. This reduces class file size.
  • Ask your graphic designer if he can reduce the image sizes.

Unlike desktop or web applications J2ME comes with the extra baggage of file sizes. Make sure at the design stage all these issues are taken care and a careful analysis should be done regarding the JAR file sizes.


Read  a File In J2MiPhone Programming FundamentalsE

Hi friends, this month j2me lesson I will go to describe how to read a specified file in J2ME. Actually In here you can read lot of file formats and can get file data as an input to the J2ME program. In this application I will creating a “help.txt” file and read data of this file by the help of J2ME Midlet.

First of all you have to open j2me project on Netbeans IDE, then create package like src. After that right click on the src package and select MIDlet and name it as ReadDisplayFile.Then you have to create text file “help.txt” on src pckage, it contains “!!!!!!!!!Welcome To diGIT IT Magzine!!!!!!!!!!!”.

(1)    When you run the Application you can see following  application

(2)    Source code

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;



* @author Manoj Alwis


public class ReadDisplayFile extends MIDlet implements CommandListener


private Display display;                        // Reference to Display object

private Form fmMain;                          // Main form

private Command cmHelp;                 / / Command to show a help file

private Command cmExit;                  // Command to exit the MIDlet

private Alert alHelp;                            // Alert to display help file text

public ReadDisplayFile()


display = Display.getDisplay(this);

cmHelp = new Command(“Help”, Command.SCREEN, 1);

cmExit = new Command(“Exit”, Command.EXIT, 1);

fmMain = new Form(“Read File”);





public void startApp()




public void pauseApp()

{ }

public void destroyApp(boolean unconditional)

{ }

public void commandAction(Command c, Displayable s)


if (c == cmHelp)


String str;

if ((str = readHelpText()) != null)                         // Access the resource and read its contents


// Create an Alert to display the help text

alHelp = new Alert(“Help”, str, null, null);


display.setCurrent(alHelp, fmMain);



else if (c == cmExit)






private String readHelpText()


InputStream is = getClass().getResourceAsStream(“help”);



StringBuffer sb = new StringBuffer();

int chr, i = 0;

// Read until the end of the stream

while ((chr = != -1)

sb.append((char) chr);

return sb.toString();


catch (Exception e)


System.out.println(“Unable to create stream”);


return null;




Change the resolution of Mobile Java game


iPhone Programming Fundamentals

An understanding of outlets and actions is one of the first things you will need for iPhone programming. For someone coming from the .NET background, this is a concept that requires some time to get used to – the concepts are similar, but it is a different way of doing things.

And so, in this article, I am going to show you what outlets and actions are. At the end of this article, you will have a solid understanding of how to create outlets and actions, and be on your way to creating great iPhone apps.

more ……..


Using Google Maps in Android

Google Maps is one of the many applications bundled with the Android platform. In addition to simply using the Maps application, you can also embed it into your own applications and make it do some very cool things. In this article, I will show you how to use Google Maps in your Android applications and how to programmatically perform the following: Change the views of Google Maps Obtain the latitude and longitude of locations in Google Maps Perform geocoding and reverse geocoding Add markers to Google Maps



Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: