N97 MIDlet.platformRequest Bug
Hi,
Currently I am developing an application for N97, and I have this problem and I believe it is a bug in the firmware.
When you call a platformRequest method inside a keyPressed call back method of the canvas, the AMS keeps firing the keyPressed in infinite loop.
The following code shows how to reproduce the problem. This bizarre behavior happens randomly when you click different buttons, sometimes when you click the A button and sometimes when you hit another button. After the phone prompt you about initiate the call press no to see the problem.
[B]The MIDlet:[/B]
[CODE]import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class TestCall extends MIDlet{
private static TestCall instance;
public static TestCall getInstance() {
return instance;
}
public TestCall() {
instance = this;
}
public void startApp() {
MyCanvas c = new MyCanvas();
Display.getDisplay(this).setCurrent( c );
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void exit() {
destroyApp( true );
notifyDestroyed();
}
}
[/CODE]
[B]The Canvas[/B]
[CODE]
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
public class MyCanvas extends Canvas implements CommandListener {
private static Command cmdExit = new Command( "Exit", Command.EXIT, 0 );
int pressed = 0;
String needExit = "";
public MyCanvas() {
addCommand( cmdExit );
setCommandListener(this);
}
protected void paint(Graphics g) {
g.setColor(0xFFFFFF);
g.fillRect(0, 0, getWidth(), getHeight() );
g.setColor(0);
g.drawString( "Pressed: " + pressed + ", " + needExit, getWidth()/2, getHeight()/2, Graphics.TOP | Graphics.HCENTER );
}
protected void keyPressed( int keycode ) {
pressed++;
repaint();
serviceRepaints();
if( pressed <= 3 ) {
Call( "+962795398738" );
}
}
public void Call(String number) {
String tel="tel:";
tel = tel + number;
try {
boolean exit = TestCall.getInstance().platformRequest(tel);
if( exit ) {
needExit = "needing exit";
} else {
needExit = "Not needing exit";
}
} catch (ConnectionNotFoundException ex) {
ex.printStackTrace();
}
}
public void commandAction(Command c, Displayable arg1) {
if( c == cmdExit ) {
TestCall.getInstance().exit();
}
}
}
[/CODE]
Re: N97 MIDlet.platformRequest Bug
Hi muqawem,
Do you experience the same problems as dakoz described in this thread?
[url]http://discussion.forum.nokia.com/forum/showthread.php?t=170724[/url]
Br,
Ilkka
Re: N97 MIDlet.platformRequest Bug
Hi isalento,
yes, I am exactly experience the same problem, and I've read one of the responses that say we should test it using the commandAction, and the problem not appeared, it happens only using the keyPressed of the canvas class. I test the code I'm attaching here using N97 over Nokia RDA.