See the code below:
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
public class KeyAnimation extends MIDlet implements CommandListener{
private Display display;
protected boolean started;
private Command exitCommand;
protected void startApp() {
//for debugging
System.out.println("I'm starting!!! - " + started);
if (!started) {
display = Display.getDisplay(this);
Canvas canvas = new KeyFinderCanvas();
exitCommand = new Command("Exit", Command.EXIT, 0);
canvas.addCommand(exitCommand);
canvas.setCommandListener(this);
display.setCurrent(canvas);
started = true;
System.out.println("Application Started! Yay! - " + started);
}
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
// Exit. No need to call destroyApp
// because it is empty.
notifyDestroyed();
}
}
}
//KeyFinderCanvas is a separate canvas which displays keys and codes
class KeyFinderCanvas extends Canvas {
static int[] keyCodes = {KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4,
KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9,
KEY_POUND, KEY_STAR};
static String[] keyNames = {"KEY_NUM0", "KEY_NUM1", "KEY_NUM2", "KEY_NUM3", "KEY_NUM4",
"KEY_NUM5", "KEY_NUM6", "KEY_NUM7", "KEY_NUM8", "KEY_NUM9",
"KEY_POUND", "KEY_STAR"};
static int[] gameActions = {
UP, DOWN, LEFT, RIGHT, FIRE,
GAME_A, GAME_B, GAME_C, GAME_D};
static String[] gameNames = {
"UP", "DOWN", "LEFT", "RIGHT", "FIRE",
"GAME_A", "GAME_B", "GAME_C", "GAME_D" };
int lastKeyCode = 0;
int lastX;
int lastY;
boolean pointer;
protected void keyPressed(int keyCode) {
lastKeyCode = keyCode;
repaint();
}
protected void keyRepeated(int keyCode) {
lastKeyCode = keyCode;
repaint();
}
protected void keyReleased(int keyCode) {
lastKeyCode = 0;
//repaint();
}
protected void pointerPressed(int x, int y) {
lastX = x;
lastY = y;
pointer = true;
repaint();
}
protected void pointerDragged(int x, int y) {
lastX = x;
lastY = y;
pointer = true;
repaint();
}
protected void pointerReleased(int x, int y) {
pointer = false;
repaint();
}
protected void paint(Graphics g) {
g.setColor(0xffffff);
//this is not smart, instead of doing this - what would you do?
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0);
if (lastKeyCode != 0) {
String keyText = "keyCode " + lastKeyCode;
String keyName = null;
// See if it is a standard key
for (int i = 0; i < keyCodes.length; i++) {
if (lastKeyCode == keyCodes[i]) {
keyName = keyNames[i];
break;
}
}
if (keyName == null) {
// See if it is a game action
for (int i = 0; i < gameActions.length; i++) {
if (lastKeyCode == getKeyCode(gameActions[i])) {
keyName = gameNames[i];
break;
}
}
}
// g.drawString(keyText, getWidth()/2, getHeight()/2,
// Graphics.BASELINE|Graphics.HCENTER);
// if (keyName != null) {
// g.drawString(keyName, getWidth()/2, getHeight()/2 + g.getFont().getHeight(),
// Graphics.BASELINE|Graphics.HCENTER);
// }
else if (pointer) {
g.drawString("(" + lastX + ", " + lastY + ")", getWidth()/2, getHeight()/2,
Graphics.BASELINE|Graphics.HCENTER);
}
// int x1 = 0;
// int y1 = 0;
if(lastKeyCode == 49) {
g.setColor(30, 150,150);
for(int moveX = 0; moveX< getWidth(); moveX+=20){
g.fillRect(moveX,20,10,getHeight());
if(moveX == getWidth() ){
//moveX = 0;
System.out.println("moveX = " + moveX);
repaint();
break;
}
}
System.out.println("drawing No.1 ");
}
else if(lastKeyCode == 50) {
g.setColor(30, 150,150);
for(int moveX = 0; moveX< 300; moveX+=20){
g.fillArc(20,10,90,100,270, moveX);
repaint();
if(moveX == 300 ){
//moveX = 0;
System.out.println("moveX = " + moveX);
break;
}
}
System.out.println("drawing No.1 ");
//System.out.println("this is testing");
}
}
}
}
CodeTest
Tuesday, September 25, 2007Posted by Unknown at 3:56 PM 0 comments
Mankind Radar
Thursday, September 20, 2007
Searching for people? Waiting for friends? Looking for kid? Now you have a great tool to target your Mr. or Ms. Right, don't have to worried about missing important people.
Mankind Radar is a mobile application that allows you to exactly locate your familiar people. By using Java mobile technology, you can have a great visual interface to tell you where he is, how far is the distance, and which direction. With the help of embedded GPS in your phone, you can easily dynamically find the people you're looking for.
API
With the help of GPS and positioning technique, "Mankind Radar", this brand new mobile application is gonna refer to certain existing API(mobile application):
1. GPS connecting and data transferring protocol
2. Mobile Processing (for the Radar animation)
3. Reading contact information (to show their picture)
Posted by Unknown at 5:41 PM 1 comments
Favorite Mobile Application

Wii + Phone??
How do we come up with a brand new way of interact with your cell phone? ASUS J202 might have already given us a clue.
With the help from motion sensor in it, ASUS J202 can easily detect the movement of cell phone as user's command to control the cell phone itself. It has 3 axis (x,y,z) motion sensing device that can analyze how the user waved his phone, and use the parameter from sensor to execute related application.
For instance, the detected motion can be used to control the Java game embedded in the phone. In the game "Speedy Scooter", a motorcycle racing game, user wave his cell phone left and right, to steer the driving direction, to make a turn. Or in "Hit Revolution", a drum beat game, user wave his cell phone up & down, to simulate the movement of a drum stick to play the game.
Other application might be developed for different usage. Maybe one day when we want to hang up the phone call, we might be able to literarily "hang up " a phone call.
Official Website:
Posted by Unknown at 11:05 AM 0 comments

