×

Discussion Board

Results 1 to 3 of 3

Threaded View

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    6

    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.

    The MIDlet:

    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();
                
       }
        
    }
    The Canvas
    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();
                
            }
            
        }
         
    }
    Last edited by muqawem; 2009-06-16 at 14:26.

Similar Threads

  1. RecordStore bug on Series 60
    By ncerezo2 in forum Mobile Java General
    Replies: 21
    Last Post: 2009-11-26, 10:12
  2. Serious BUG in Nokia phones!!!
    By bartekn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 10
    Last Post: 2004-03-28, 22:09
  3. A bug: setColor with offscreen graphics - PLEASE, REPLY THIS TIME
    By palmcrust in forum Mobile Java General
    Replies: 11
    Last Post: 2003-12-04, 12:43
  4. Firmware bug or code bug displaying list on 3650
    By blackjack75 in forum Mobile Java General
    Replies: 2
    Last Post: 2003-09-24, 19:52
  5. Replies: 8
    Last Post: 2003-07-11, 12:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×