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.
The MIDlet:
The CanvasCode: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: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(); } } }

Reply With Quote

