Google

Tuesday, December 30, 2008

How to calculate FPS

public UFOCanvas(Display d) {
super(true);
display = d;
// Set the frame rate (30 fps)
frameDelay = 33;
}

To get fps:

(1/frameDelay) x 1000
= (1/33)*1000
= 30 fps

Monday, December 29, 2008

Nokia N78 Full Specification




3G Phone, GPS, Flash Lite 3

JSR 135 Mobile Media API

JSR 172 Web Services API

JSR 177 Security and Trust Services API

JSR 179 Location API

JSR 180 SIP API

JSR 184 Mobile 3D Graphics API

JSR 185 JTWI

JSR 205 Wireless Messaging API

JSR 226 Scalable 2D Vector Graphics API

JSR 234 Advanced Multimedia Supplements

JSR 248 Mobile Service Architecture for CLDC

JSR 75 FileConnection and PIM API

JSR 82 Bluetooth API v1.1

MIDP 2.1

See Full Specs here

Kicking Butt with MIDP and MSA 2008 - latest book on J2ME




Download SourceCode

Sunday, December 28, 2008

Bluetooth Application Programming




Bluetooth Application Programming Book source code website

Project Capuchin in 3 mobile phones


Project Capuchin in 3 phone series

Sony Ericsson now offers three phone models with Project Capuchin – increasing the addressable market for developers – and the new W705 joins the previously announced C905 Cyber-shot™ and G705 phones.

Link

Wednesday, December 17, 2008

Monday, December 15, 2008

World Clock 0.0.38 Released

World Clock Version 0.0.38 is completed.
Download

Splash Screen:

Select Country,City:


Real-time Clock:

Sony Ericsson SDK for the Java ME platform 2.5.0.3

Downloaded Sony Ericsson's latest SDK (111 MB). About twice
the size of Nokia SDK.

During installation in Vista I get error message:

"WTK2 emulator needs VoiceAge.DLL in order to work"

This error indicates that the VBScript DLL is not properly registered
on the Vista machine.

To solve this, open the cmd shell as Adminstrator (Right click
on the cmd icon from Start menu and Run as Adminstrator).
Then execute this command whilst in the default system32
directory:

regsvr32 vbscript.dll

( http://developer.sonyericsson.com/message/119457 )

Later after trying again to install, another message came up:

"Need to close this program before continuing: jsl.exe"

Just click next, the installer will kill the process and continue.

After installation, the process to link the SDK to Netbeans 6.5 is
the same as for the Nokia SDK.

However, you will note that there are two platforms added.
The first one is as shown below, Debug On-Device SDK.



The second one is the Emulator. See below:



When running tests, you should use the Emulator. There are many
Sony Ericsson mobile phone models. For example, K510:

The above K510 emulator is running the World Clock Program
that I have written.

Sunday, December 14, 2008

Java and Pixie OS

Pixies OS which is used to run G.ho.st on mobile devices
is developed using Java.

Supported mobile phones.

Saturday, December 13, 2008

Netbeans 6.5 installation

At time of writing, Netbeans 6.5 is the latest edition.
After downloading from netbeans.org, the barebones
edition i.e. the Netbeans 6.5 SE, it does not come with
JWTK 2.5.2. You will need to add it as a Platform
by clicking on the Tools menu, then Java Platform,
then add Java Platform.

But before you can do that, you will need to install
a plugin first. Goto Tools, then Plugins, then add the
mobility plugin. It's around 9 MB to download.

After intsalling that, then only add the JWTK Platform.

Two other optional plugins are the mobility vmd and
mobility end-to-end.

moility vmd enables you to design the midlet's
GUI visually and also has flow layout view.

Workaround to List Bug in Nokia SDK 6th Edition

Running the application compiled under SDK 5th edition
on the SDK 6th edition's emulator:


A temporary work-around to the List Bug:

In Netbeans 6.5, compile the application using SDK 5.

Then fire up your SDK 6 emulator (outside of Netbeans 6.5).
Use the File menu, navigate to the dist folder of the Netbeans
project. You will find a .jad and a .jar file there.
Open the .jad file (emulator will then execute the .jar).
The above image is the result. Works like
a charm! This temporary workaround will do for now,
while waiting for Nokia to fix the bug.

Friday, December 12, 2008

List Bug in Nokia Series 40 SDK 6th edition

Using Nokia Series 40 Emulator Edition 5:



TheList Bug:

I found a new bug in Nokia Series 40 SDK Edition 6
(which was released last month: Nov, 2008), which I
now call the 'List' Bug.

I tried to compile the following code:

private String sCities[]={"KL","PG"};
private int hr, min;

public WorldClock() throws IOException {

citylist=new List("World Clock 0.0.22",List.IMPLICIT,sCities,null);
cmExit = new Command("Exit", Command.ITEM, 2);
citylist.addCommand(cmExit);
citylist.setCommandListener(this);

}


And it raised this compiler error:

class file for javax.microedition.lcdui.ChoiceVector not found
citylist=new List("World Clock 0.0.22",List.IMPLICIT,sCities,null);


I then downloaded the earlier Edition 5 (2007) and it compiled fine.

It appears that Edition 6 SDK wrongly called the non-existent
ChoiceVector to create the List.


Status of World Clock Project:

As can be seen in image above, I am now able to simulate
an analog clock in real-time.

Thursday, December 11, 2008

World Clock Project using Nokia Series 40 Emulator Edition 6

This is what it looks like using the Nokia Series 40 Emulator Edition 6:



You need to integrate the Nokia SDK to Netbeans 6.5 first.
From Tools Menu select Java Platforms then select
C:\Nokia\Devices\S40_6th_Edition_SDK

The project is not finished yet. The above is just a testrun
on the initial clockface design.

Wednesday, December 10, 2008

Nokia Series 40 Platform SDK - J2ME

Series 40 Platform SDKs


Joined Nokia Developer Forum and downloaded Series 40 SDK:



Latest news

The initial release of the Series 40 6th Edition SDKs is now available. This initial SDK offers developers the ability to build and test applications that use JSR-179, the analogue joystick feature, and the HVGA display on the Nokia 6260 slide phone.

A full and final version of the SDK will be available at a later date.

Supported runtimes

Development of applications using Java™ technology and Flash Lite is supported by the SDKs.

Supported content

Creation of web and messaging content is supported by the SDKs.

Supported editions and feature packs

The Series 40 SDKs are available for the following editions and feature packs:

  • Series 40 6th Edition.
  • Series 40 5th Edition, Feature Pack 1.
  • Series 40 5th Edition.
  • Series 40 3rd Edition, Feature Pack 2.
  • Series 40 3rd Edition, Feature Pack 1.
  • Series 40 3rd Edition.
  • Series 40 2nd Edition (Series 40 2.0)
Download from Nokia

Series 40 6th edition V 0.9

World Clock for Mobile Phone Project Takes Off

World Clock for Mobile Phone:
(the screen so far)



Objective:

To develop a world clock that runs on mobile phones. User
will be able to select country and city and get a visual clock
on the display.


Resources:


Inputting time via a clock face using DateField

Tuesday, December 9, 2008

Sunday, December 7, 2008

Simplest MultiThreading Hello App in J2ME

Below is the simplest multi-threading application in
J2ME.

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


public class HelloByThread extends MIDlet implements CommandListener{
private Command exitCommand,sayhelloCommand;
private Display display;
private Form fmMain;
private TextField helloField;

public HelloByThread(){
fmMain=new Form("Main Form");
exitCommand=new Command("Exit",Command.SCREEN,1);
sayhelloCommand=new Command("Say Hello",Command.ITEM,2);
fmMain.addCommand(exitCommand);
fmMain.addCommand(sayhelloCommand);
fmMain.setCommandListener(this);
}

public void startApp() {
display=Display.getDisplay(this);
display.setCurrent(fmMain);
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable d) {
if(c==sayhelloCommand){
HelloSayer hs=new HelloSayer(this);
hs.start();
}
else if(c==exitCommand){
destroyApp(false);
notifyDestroyed();
}
}

public void sayHello(){
fmMain.append("Hello Paul");
}
}

class HelloSayer implements Runnable{
private HelloByThread hbtMidlet;

public HelloSayer(HelloByThread hbtMidlet){
this.hbtMidlet=hbtMidlet;
}

public void run() {
hbtMidlet.sayHello();
}

public void start() {
Thread thread = new Thread(this);
try
{
thread.start();
}
catch (Exception e)
{
}
}
}

All it does is say Hello Paul. But it does so without
blocking the main System Thread.

Saturday, December 6, 2008

Mobile Phone Programming Languages

Brew by Qualcomm

List by Aalborg University

HttpConnection Class

Read this:

The HttpConnection Class by Yu Feng


Then modified my code.

The code below works for Z610i and on my PC emulator,

but fails on my T610 due to failure to open stream:

is = hc.openInputStream();

The commented out part also works on Z610i and
PC Emulator and also fails on my T610 due
to failure to open stream:

in = conn.openInputStream();


package MyMobilePractice2;

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



public class Fortune extends MIDlet implements CommandListener {
private Command exitCommand, nextCommand;
private Display display;
private Form screen;
private StringItem fortuneItem;
private Vector fortunes;

public Fortune() {
// Get the Display object for the MIDlet
display = Display.getDisplay(this);
// Create the Exit and Next commands
exitCommand = new Command("Exit", Command.ITEM, 2);
nextCommand = new Command("Next", Command.ITEM, 2);
// Create the main screen form
screen = new Form("Fortune of the Day");
fortuneItem = new StringItem("", "Reading fortunes...");
screen.append(fortuneItem);
// Set the Exit and Next commands for the screen
screen.addCommand(exitCommand);
screen.addCommand(nextCommand);
screen.setCommandListener(this);
// Create the fortunes vector
fortunes = new Vector();
}
public void startApp() throws MIDletStateChangeException {
// Set the current display to the location screen
display.setCurrent(screen);
// Initialize the fortunes vector
readFortunes();
// Show the first random fortune
showFortune();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
else if (c == nextCommand) {
// Show the next random fortune
showFortune();
}
}

private void readFortunes(){
StringBuffer data = new StringBuffer();
HttpConnection hc= null;
InputStream is=null;
try{
hc=(HttpConnection)Connector.open("http://putyourwebsite.here/Fortunes.html");
}
catch(Exception e){
Alert httpAlert=new Alert("HTTP","fail",null,AlertType.ERROR);
httpAlert.setTimeout(Alert.FOREVER);
display.setCurrent(httpAlert);
return;
}
try{
is = hc.openInputStream();
}
catch(Exception ex){
Alert streamAlert=new Alert("STREAM","fail",null,AlertType.ERROR);
streamAlert.setTimeout(Alert.FOREVER);
display.setCurrent(streamAlert);
return;
}

// Read a line at a time from the input stream
int ch;
boolean done = false;
try{
while ((ch = is.read()) != -1) {
if (ch != '\n') {
// Read the line a character at a time
data.append((char)ch);
}
else {
// Add the fortune to the fortunes vector
fortunes.addElement(data.toString());
// Clear the string for the next line
data = new StringBuffer();
}
}
}
catch(Exception e){}

}

// private void readFortunes() {
// StreamConnection conn = null;
// InputStream in = null;
// StringBuffer data = new StringBuffer();
// try {
// // Open the HTTP connection
// conn = (StreamConnection)Connector.open("http://192.168.20.3/Fortunes.txt");
// // Obtain an input stream for the connection
// in = conn.openInputStream();
// // Read a line at a time from the input stream
// int ch;
// boolean done = false;
// while ((ch = in.read()) != -1) {
// if (ch != '\n') {
// // Read the line a character at a time
// data.append((char)ch);
// }
// else {
// // Add the fortune to the fortunes vector
// fortunes.addElement(data.toString());
// // Clear the string for the next line
// data = new StringBuffer();
// }
// }
// }
// catch (IOException e) {
// System.err.println("The connection could not be established.");
// }
// }
//
private void showFortune() {
// Check to make sure the fortunes vector isn’t empty
if (!fortunes.isEmpty()) {
// Create and seed the random number generator
Random rand = new Random(Calendar.getInstance().getTime().getTime());
// Set a random fortune
int fortuneNum = Math.abs(rand.nextInt()) % fortunes.size();
fortuneItem.setText((String)fortunes.elementAt(fortuneNum));
}
else
fortuneItem.setText("No fortune!");
}
}

Friday, December 5, 2008

To activate GPRS on Sony Ericsson T610

Note that the autosetting sent via SMS does not work for T610
although it used to.


To activate GPRS on Sony Ericsson T610 - Maxis Website

To activate GPRS *1333 Then Send

Then configure as follows:

Configure your phone
Please make sure that you have subscribed for Maxis' GPRS services.
1. Enter the main menu and select Connectivity.
2. Select WAP options.
3. Enter WAP profiles.
4. Select New profile.
5. ClickAdd.
6. Enter Name: Maxis WAP (GPRS).
7. Select Connect using.
8. Select Add New account.
9. Select Account type: GPRS data
10. Enter Name of New account: Maxis WAP (GPRS)
11. Enter APN: net
12. Enter User id: maxis
13. Enter Password: wap
14. Click Save.
15. Click Maxis WAP (GPRS).
16. Enter IP address: 202.075.133.049
17. Click Save.
18. From the WAP profiles menu, highlight your newly created profile and select Edit.
19. Select Advanced.
20. Enter Change homepage: http://wap.maxis.com.my/wml/
index.wml
21. Press the back arrow key and go to Connectivity menu.
22. Select Data comm.
23. Select Data accounts.
24. Highlight your newly created profile and select Edit.
25. Select Advanced settings.
26. Select Authentication: Normal
27. Leave the other settings as default.