How to get Phone IMEI number with J2ME / JavaME

International Mobile Equipment Identity (IMEI) is used to identify valid devices connected to GSM and UMTS network. This number can be accessed from a mobile phone by dialing *#06# on the keypad. IMEI is commonly use by software developers as part of software protection scheme to prevent it from being pirated.

JavaME developers however suffers from a drawback because MIDP/CLDC specification does not include an API to obtain IMEI from mobile devices. However there are few phone manufacturers included this functionality through System.getPropery() calls.

Here’s how to get IMEI number from mobile devices of different manufacturers
Nokia

System.getProperty("phone.imei");
System.getProperty("com.nokia.IMEI");

Note ; Requires signed midlet. S60 3rd edition device does not requires signing for this to work.

Sony-Ericsson

System.getProperty("com.sonyericsson.imei");

Note ; might not work on all model, YMMV

Motorola

System.getProperty("IMEI");
System.getProperty("com.motorola.IMEI");

Samsung

System.getProperty("com.samsung.imei");

Siemens

System.getProperty("com.siemens.imei");

Hopefully this information can aid you in your J2ME programming projects.

Quick Tip :
It’s quite hard to determine the phone model/manufacturer well ahead beforehand. For a more robust solution, I suggest that you combine the above call with System.getProperty(“microedition.platform”).

[tags]j2me,javame,mobile,opensource,imei,nokia,sony ericsson,samsung,motorola[/tags]


Cool J2ME Game Demo – Opposite Lock

October 9th, 2007 1 Comment   Posted in J2ME / JavaME, Mobile Games, Sony Ericsson

Here’s a video clip from the Grand Prize winner of Java Mobile Application Video Contest organized by Sun.

The demo feature a Mobile Java (j2me) car racing game called Opposite Lock. Enjoy the video.

[coolplayer width="425" height="360" autoplay="0" loop="0" charset="utf-8" download="1" mediatype=""]
J2ME Opposite Lock Game
[/coolplayer]

You can download and buy Opposite Lock from clickgamer.com

Download J2ME WheelItem CustomItem

October 6th, 2007 1 Comment   Posted in J2ME / JavaME

This is an example of J2ME / JavaME CustomItem called WheelItem. It does nothing beside showing a spinning wheel on the phone screen. WheelItem is a perfect candidate to be displayed on a wait form screen replacing Gauge class while your application is performing lengthy operating.

WheelItem Screenshot

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;

public class WheelItem extends CustomItem
{
  private int mCount,mMaximum;
  private int mInterval;
  private int mWidth,mHeight,mX,mY,mRadius;
  private String mMessage;

public WheelItem(String title)
{
	super(title);
	mCount=0;
	mMaximum = 36;
	mInterval = 100;

	TimerTask task = new TimerTask() {
		public void run() {
			mCount = (mCount+1) % mMaximum;
			repaint();
		}
	};
	Timer timer = new Timer();
	timer.schedule(task,0,mInterval);
}
	public void setString(String string)
	{
		mMessage = string;
		repaint();
	}

	public void paint(Graphics g, int iWidth, int iHeight) {
		mWidth = iWidth;
		mHeight = iHeight;
		int halfWidth = mWidth/2;
		int halfHeight = mHeight/2;

		mRadius = Math.min(halfWidth,halfHeight);
		mX = halfWidth - mRadius/2;
		mY = halfHeight - mRadius/2;

		int theta = -(mCount*360/mMaximum);

		g.setColor(255,255,255);
		g.fillRect(0,0,mWidth,mHeight);
		g.setColor(0,0,0);
		g.drawArc(mX,mY,mRadius,mRadius,0,360);
		g.fillArc(mX,mY,mRadius,mRadius,theta+90,90);
		g.fillArc(mX,mY,mRadius,mRadius,theta+270,90);

		if (mMessage !=null)
		{
			g.drawString(mMessage,mWidth/2,mHeight,Graphics.BOTTOM | Graphics.HCENTER);
		}
	}
  public int getMinContentWidth() { return 80; }
  public int getMinContentHeight() { return 80; }
  public int getPrefContentWidth(int width) {return getMinContentWidth();}
  public int getPrefContentHeight(int height) {return getMinContentHeight();}
}

Download example application with WheelItem source : WaitFormDemo.zip

Ported (rather poorly) from Wheel canvas written by Jonathan Knudsen from his article – Networking, User Experiences and Threads.

Any suggestions or improvements are welcomed!

iPhoneCanvas – Fancy List component class for J2ME

October 1st, 2007 1 Comment   Posted in J2ME / JavaME, Open Source

I found a really nice but simple to use fancy list chooser class that emulates an iPhone display. The class requires MIDP 2.0 supported phones and can replace the default and boring List chooser class into a stunning, smooth scrolling graphical menu (includes reflections) for your users to see

Here’s example screenshot of iPhoneCanvas demo in action :

These menu icons are generated from flat and boring thumbnails like these :

Download
iPhoneCanvas is licensed under the GNU General Public License and can be downloaded from listchooser Google Code project page

Demo
The iPhoneCanvas demo featured in above screenshot can be downloaded here – fancylist.jar, fancylist.zip (demo source code)

Please submit bug reports or suggestions at Google Code listchooser page

How to generate Random Numbers in J2ME application

September 28th, 2007 5 Comments   Posted in J2ME / JavaME, Java, newbie, Tips, Tricks, Guide

One of the popular question asked in this blog is ways to generate random numbers in J2ME application.

As most people probably realized, the JavaME CLDC does not include the Math.Random class to generate random numbers. However one can generate a series of random numbers in JavaME/J2ME application by using the included java.util.Random class.

Here’s a sample usage

import java.util.Random;
...
	Random generator = new Random();
	generator.setSeed(System.currentTimeMillis());
	float f = generator.nextFloat();

	System.out.println(""+(f*100.0f)%100);
...

The sample code above will produce a random floating-point number between 0..100 (exclusive)

Here’s the source code for the full Random Number Demo application : RandomDemo.java,

Foxrate – Open Source J2ME Currency Converter Mobile Application

September 28th, 2007 9 Comments   Posted in J2ME / JavaME, Mobile Software, Open Source, PDA
open source j2me currency converter

Foxrate mobile is a currency converter application for mobile devices. It is a relatively small application which supports converting from/to 35 different currencies used around the world.

Foxrate lifts you from the burden of updating currency rate by automatically retrieving latest currency information from remote server. The best part about foxrate is — it is available for free and open source!

Download Foxrate Mobile Currency Converter
Foxrate can downloaded from- Google Code’s Foxrate page and Getjar.com

Presentation Slides for 10 Sept UUM Sintok Class Talk (AP Hatim)

September 10th, 2007 1 Comment   Posted in J2ME / JavaME, newbie, Tips, Tricks, Guide

Here is the presentation slides of the 10 Sept 2007 Network Content & Applications in Mobile Devices – Assoc Prof. Hatim Mohamad Tahir class at UUM Sintok.

[tags]sintok,malaysia,uum,presentation,slides,mobile,j2me,javame,webservice,web service,xmlrpc,xml-rpc,soap[/tags]


The best J2ME MIDlet icon size settings

Although not required, It is nice to include icon in your MIDlet distribution as it give a unique feeling to your mobile application. The only problem is different device seems to have different icon sizes requirements for tJ2ME MIDlet.

The Ideal Icon size guidelines for different mobile device
Here is the icon size guideline for different devices

Nokia

  • Series 40 – 128×160=24×24, 208×208=46×46, 240×320=46×48
  • S60 1st and 2nd – 176×208=42×29, 352×416=76×76
  • S60 3rd – 176×208=31×31, 208×176=37×37, 352×416=76×76, 240×320=53×53/55×55, 320×240=52×52/54×54, 208×208=37×37
  • N90/N95 : 84×58

Samsung & Sony Ericsson
Most Samsung phone accept 16×16, 32×32 icon size

Motorola
15×15, 16×16, 32×32

Most phone seems to accept 8bit-depth color for MIDlet icons, except Nokia S60 3rd edition which seems display 24bit icon quite well.

Note that most of this figure are based on experiments and observation on different phone models.

[tags]midlet,java,j2me,javame,midp,midp2,symbian,nokia,motorola,sony ericsson[/tags]


Create Chart Easily on with J2me ChartComponent class

September 10th, 2007 No Comments   Posted in J2ME / JavaME, newbie

Charts and graphs are very convenient and efficient way to present data to audiences. Charts make it easy for people to compare figures and present an interpretation of the data itself with just a glance.

However writing a class to represent data in charts in J2ME environment is very time consuming if not difficult, especially when the data representation part consists of a very small part of your mobile application.

Fortunately, there’s ChartComponent, an easy to use class for generating charts in J2ME JavaME applications. ChartComponent requires MIDP 2.0 / CLDC 1.0 supported phone in order to be use.

Supported charts in the class are :

  1. Horizontal bars
  2. Vertical bars
  3. Line
  4. Pie (experimental)

ChartComponents comes with javadoc API documentation for references and a test suite which serves as a demo and code reference. The only drawback that I found with are : It is not open source, it is quite large.

However the ChartComponent jar class size can be reduced after integrating with your own midlet with the use of obfuscater.

Download ChartComponent from Beanizer.org

pie.png
palm.gif

[tags]j2me,javame,charts,mobile,midp,cldc,java,midp2[/tags]


YMTiny the no nonsense mobile Yahoo Messenger – j2me javame

shot.gif

Forget about other bloated mobile YM messenger, YMTiny is a lean Yahoo Messenger that does it best — enabling you to keep in-touch with your YM contacts!

Written in JavaME, the YMTiny has been tested (and works) on various popular phones that supports at least MIDP 2.0/CLDC 1.0 specification.

YMTiny feature simple login and buddy list user interface that makes it easy to use in a small-screen environment.

Among of the feature supported in YMTiny are :

  • Audible message alerts for BUZZ and chats
  • Vibrate/Backlight flashing feature
  • Configurable font, supports bitmap font and system font.
  • “Smart Ping” maintains connection and minimizes bandwidth usage
  • Receives offline messages, new mail and typing notifications
  • Show and hide offline friends
  • Window and forms animations

YMTiny can be downloaded from YMTiny project’s website and from Getjar

p/s : I’ve personally tested YMTiny on my 6630 and Dopod P800W (using the default Intent MIDlet Manager) — the application works perfectly out from the box!

Download YMTiny now!

[tags]ym,yahoo,yahoo messenger,mobile,java,javame,j2me[/tags]


This blog is protected by dr Dave\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'s Spam Karma 2: 174419 Spams eaten and counting...