Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2006

    Application startup fails in N72, static initialization is to blame ?


    I wrote the following small code . It compiles an works fine in wtk emulator. But it just does not run in N72.

    Then I tried to remove the static final fields one by one .. I did not try all of them , But removing some commands or removing the alert fixes the problem.

    Also if I go lazy, initialize the variables in the startApp(), then this is not a problem.

    Is it some kind of memory exception or a new bug revealed ?

     * @author Kamanashis Roy
    package net.ayaslive.miniim.ui;
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    public class App extends MIDlet implements CommandListener {
            private static App self = null;
            private static Alert singleAlert = new Alert("TEST");
            private final static Command YES_POSITIVE = new Command("YES", Command.OK, 1);
            private final static Command NO_POSITIVE = new Command("NO", Command.CANCEL, 1);
            private final static Command YES_NEGATIVE = new Command("YES", Command.CANCEL, 1);
            private final static Command NO_NEGATIVE = new Command("NO", Command.OK, 1);
            private final static Command OK_CMD = new Command("OK", Command.BACK, 1);
            public void destroyApp(boolean unconditional) {
            protected void pauseApp() {
            public void commandAction(Command cmd, Displayable dis) {
             * Startup step
            private int step = 0;
            protected void startApp() throws MIDletStateChangeException {
                    try {
                            Canvas canvas = new Canvas() {
                                    protected void paint(Graphics g) {
                                            final int height = getHeight();
                                            final int width = getWidth();
                                            final int halfHeight = height/2;
                                            final int RESOLUTION = 15;
                                            final int PADDING = 2;
                                            final int fillWidth = width - RESOLUTION - RESOLUTION;
                                            // clear
                                            g.fillRect(0, 0, width, height);
                                            // fill step%
                                            g.fillRect( RESOLUTION, halfHeight - RESOLUTION, fillWidth*step/100, RESOLUTION);
                                            g.drawRoundRect(RESOLUTION, halfHeight - RESOLUTION, fillWidth, RESOLUTION, PADDING, PADDING);
                            // show the canvas
                            // show progress
                            for(int i=0; i<100; i+=10) {
                                    this.step = i;
                            // cleanup
                            canvas = null;
                    } catch(Throwable t) {

  2. #2
    Nokia Developer Expert
    Join Date
    May 2007
    Mexico D.F

    Re: Application startup fails in N72, static initialization is to blame ?


    Tested your code in a Nokia 6682 (S60 2nd Edition FP2) and worked fine.

    Could you give us more details about the error you get... any message?

    My feeling is that could be a problem at packing the MIDLet... check that Jad file is correct.

    Remember not to initialize variables in the startApp method ... you should do it in the MIDLet constructor... the reason is that startApp could be called more than once during the lifetime of the application.

    : Ruben

  3. #3
    Registered User
    Join Date
    Oct 2006

    Re: Application startup fails in N72, static initialization is to blame ?


    Thank you for your reply. And "not initialize in startApp" is really new thing for me . The problem is when I start the application, there is a flicker and the application goes dead.

    Note, I tested it on N72(V 5.0734.4.0.1 22-08-07 RM-180) ..

    Today I double checked the code with the same result. Earlier I used antenna, now tested with WTK 2.5.2 .. (could not find a way to attach, but the jar and jad is hosted here<http://miniim.sourceforge.net/n72tests> for some days, may be it can help)

    Let me know if you want to know any information ..

    -- Thanks

Similar Threads

  1. Starting browser from application in N72
    By kumar_sai123 in forum Symbian
    Replies: 2
    Last Post: 2008-05-29, 13:26
  2. Replies: 3
    Last Post: 2003-04-09, 18:54
  3. filtering application as a recipient?
    By aidj in forum General Messaging
    Replies: 1
    Last Post: 2002-11-12, 07:26
  4. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29
  5. Replies: 1
    Last Post: 1970-01-01, 01:00

Posting Permissions

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