• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Program behaves differently in Nokia

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have written a J2ME program and tested it using the WTK. But when I tried to run in the Nokia emulator, the splash screen doesn't appear, addition commands appear such as 'Cancel' etc. Just want to know why is this?
Thanks in advance
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I would be really happy if I can get an answer for this. Becuase I am in deep trouble trying to figure out this. I really anticipate your help. Thanks..
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J2ME programs behave differently on different devices and emulators. This is just part of life. The WTK is only a "reference implementation". It is not intended for production. You just have to dig into docs in Forum Nokia to find out why Nokia phones behave the way it is and find out how to work around with Nokia specific optimizations to your code. Knowledge about individual devices is what separates a novice from an experienced developer in this field. For your questions:

1. Did you put the splash screen in a separate thread?

2. Nokia Series 60 phones automatically adds a "cancel" command to all screens. Its commandAction method calls "destroyApp(true)". It is because you cannot stop a MIDlet on a Series 60 device by pressing the red "End call" button. The phone want to make sure that you have a way to exit your MIDlet.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
No I didn't put the splash screen in a different thread. But it is a different class. So what do I have to do? any way now I have another problem. Noramlly Java is said to be, program ones, run any where. I feel it is not true for J2ME then. So what I feel is I have to have different coding for different platforms, correct me if I am wrong..
Thank you in advance.........
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just checked in our application:
  • Nokia3650 does not auto-put a cancel button, at least in our phone and

  • Series_60_MIDP_Concept_SDK_Beta_0_3_Nokia_edition emulator.
  • However, samsung phone does put a auto-ok button there, if anybody know how to get rid of it, I'd like to know.
  • We do put the canvas, which holds the splash screen etc. in a seperate thread.
  • About Java "Compile Once, Run Everywhere", see an interesting

  • discussion here:
    http://www.coderanch.com/t/228336/JME/Mobile/Portability-vs-Quality
    [ August 29, 2004: Message edited by: Roseanne Zhang ]
     
    Michael Yuan
    author
    Ranch Hand
    Posts: 1427
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You can NOT put the setCurrent(splashscreen) statement in startApp() or commandAction() directly. You have to put it in a separate thread, which can be started from startApp() or commandAction(). It is a bug in the WTK that allows you to show the splash screen without a background thread.

    J2ME was never about WORA. In fact, you do not hear much talk about WORA even in J2SE or J2EE these days. Any successful Java application needs to optimized for the target deployment platform.
     
    Roseanne Zhang
    Ranch Hand
    Posts: 1953
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Michael Yuan:

    ..........
    In fact, you do not hear much talk about WORA even in J2SE or J2EE these days. Any successful Java application needs to optimized for the target deployment platform.


    No, I disagree.

    My previous job world-class applications (around 0.5-20 million USD applications) do Compile Once, Run on all 4 target platforms (HP-UX, Solaris, Linux and Windows). We only need to recompile our native code, and put some platform specific things into configuration files.

    If you download Tomcat or Ant in a zip format, you can use them on any platform too. They are world class open source software and extremely successful Java applications.

    That is why we are here for Java.
    [ August 29, 2004: Message edited by: Roseanne Zhang ]
     
    Ransika deSilva
    Ranch Hand
    Posts: 524
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi all,
    Ok this is getting interesting. So I have to change the code some times, that's not a problem for me.
    No I didn't put setCurrent(SplashScreen) in the startApp() method. It's like this. I have a seperate class called SpalshScreen which extends a Canvas and I am using an Alert to show the image(splash image), in the paint() method I have setCurrent(Alert). It works fine in the WTK but not in the nokia emulator. Please explain this to me. Thank you.
     
    Michael Yuan
    author
    Ranch Hand
    Posts: 1427
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Calling setCurrent() from paint() could easily dead-lock you application since they both run in the UI thread. You should not use paint() for anything other than painting the screen. If you have to display the splash screen from paint(), you still need to put it in a separate thread and start that thread from paint().
     
    Roseanne Zhang
    Ranch Hand
    Posts: 1953
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Find a J2ME book or online tutorial, play a simple example in it. Then you will understand what Dr. Yuan taught you about the right way to use a seperate thread.

    There're many different ways to make your program does not work as expected. Nobody is surposed to know what you did wrong.
     
    Ransika deSilva
    Ranch Hand
    Posts: 524
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,
    Ok I will try what Dr.Y has said. I just wanted to get the expertise comments, that's why I asked to explain why I am not getting the splash screen. Yes I know nobody is supposed to explain what I did wrong. Thanks any way for the help you have extended so far.
     
    Ransika deSilva
    Ranch Hand
    Posts: 524
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,
    I just want to get this clear, Dr.Y says to put the splash screen in a different thread. Here what does 'thread' mean. Is it a class which inherits from the Thread class or just another simple class. Thank you very much..
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic