4

I am developing a mobile application using J2ME and LWUIT. Whenever the default exit Button (red in color) is pressed on a phone with symbian OS , I want my application to be minimized and not exited. How do i achieve this?

Nikhil
  • 1,279
  • 2
  • 23
  • 43

2 Answers2

6

According to Nokia documentation at http://library.developer.nokia.com/index.jsp?topic=/Java_Developers_Library/GUID-C5D3E0F5-72B9-4EE7-8BA7-20DE4A538FB8.html you can add the following jad key: Nokia-MIDlet-No-Exit.

"Prevents the MIDlet from closing via pressing the End key. Instead of closing the MIDlet it is put to the background. The MIDlet can be still closed from the list of open applications."

Example:
Nokia-MIDlet-No-Exit: true

Telmo Pimentel Mota
  • 4,033
  • 16
  • 22
  • this stuff aint working for me. I tried setting the jad and jar attributes to true/false. However the application still closes on 'end key press' .. any more inputs? – Nikhil Apr 01 '12 at 08:48
  • It must be set to true. How did you add it to Jad? Manually? – Telmo Pimentel Mota Apr 02 '12 at 12:36
  • Hey, i added it in netbeans..to the manifest file and set the attribute to false. But thats not working. ..anything else to try?> – Nikhil Apr 08 '12 at 05:01
  • You must set it to true and it must be on jad file. – Telmo Pimentel Mota Apr 09 '12 at 16:53
  • "It must be on jad?" Din get you... All my stuff is loaded into "Application.jar" file. – Nikhil Apr 10 '12 at 05:18
  • 1
    Maybe you already know this, but I'll say it anyway: J2ME Apps should have a Jad file. Sure, some phones will install using only Jar, but some settings must be placed into a Jad. You can take a look at http://developers.sun.com/mobility/learn/midp/lifecycle/ – Telmo Pimentel Mota Apr 12 '12 at 10:58
  • Thanks for the article. It was a good read. However , even after adding the entry to my JAD file..my app still exits on 'end key' press. This is what my jad looks like right now: MIDlet-1: ABC, , ABC MIDlet-Jar-Size: 941754 MIDlet-Jar-URL: ABC.jar MIDlet-Name: ABC! MIDlet-Vendor: Vendor MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.1 MicroEdition-Profile: MIDP-2.0 Nokia-MIDlet-No-Exit: true Any idea what could be going wrong? – Nikhil Apr 15 '12 at 04:55
  • Your Jad file seems fine. Maybe your handset does not support this key? According to Nokia documentation the Nokia-MIDlet-No-Exit key is supported since Symbian edition S60 3rd Edition FP 2. What is your handset version? – Telmo Pimentel Mota Apr 16 '12 at 11:34
  • @ Telmo I am using Nokia E63 (http://www.answers.com/topic/nokia-e63) and my OS is : Symbian OS9.2, S60 3.1 Edition – Nikhil Apr 16 '12 at 11:43
  • 2
    According to http://en.wikipedia.org/wiki/S60_%28software_platform%29 your E63 has FP1 (Feature Pack 1), and the API is only supported from FP2 onwards. – Telmo Pimentel Mota Apr 17 '12 at 11:00
  • Yes, that makes sense. So this code will work only for some handsets. Is there anyway to make it work for all (eg. my handset)? and thanks for your patience :) – Nikhil Apr 18 '12 at 06:02
3

To minimize application use following line of code::

                  Display.getDisplay (MIDLET_CLASS_NAME).setCurrent (null);

to get the screen back use the following:

                  Display.getDisplay (MIDLET_CLASS_NAME).setCurrent (myCanvas);

Where myCanvas is your canvas instantiation

this does not work on all models. (Works on Nokia s60, SonyEricsson, but not on Nokia s40, Samsung and some others.

Mr. Sajid Shaikh
  • 7,051
  • 4
  • 21
  • 35
  • ...Your answer does not do justice to my question. How do I minimize the application when the exit button of the cellphone is pressed? In nokia, its a red button. WHen you press that button, the application automatically exits. However, for a S60 , for some select applications (eg. Opera mini) when you hit the exit button, the application gets minimized. I want to do the same thing with my application. How do i do it? – Nikhil Mar 27 '12 at 03:17
  • Hey Dude check this article => 2.2 Interaction requirements, pausing the application http://www.mobileappstesting.com/tag/nokia-test-criteria-for-j2me-application/ – Mr. Sajid Shaikh Mar 27 '12 at 04:52
  • I read the article but its not clear how i can implement this? DO i need to override a method of my midlet which will capture the 'End Key' (red button) and then call some function to minimize the display? Can you provide some sample code? – Nikhil Mar 27 '12 at 08:56
  • dude some mobiles when you press "Red Button(End Key)" application will be minimize automatically, I never handled "Red button" key press before, so i don't have sample code for that, but you can try with key code (which will be applied for red key button "End Key"), that key code i don't know(May be it present or not). – Mr. Sajid Shaikh Mar 27 '12 at 09:18
  • have you checked @Telmo answer – Mr. Sajid Shaikh Mar 28 '12 at 09:12