×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    26

    Which event is fired when the midlet is maximized [maximizing without minimizing]

    Hi all,

    Anyone please help me on this.

    My midlet has the following behavior

    1. Midlet is started automatically on phone start up. //done using push registry's static invocation
    2. At this time there no UI part involved. But a thread will be started downloading files from server.
    3. It means the midlet will be running in background without any UI.
    4. When the user wants to open application[navigating through Gallery or Applications -> MyMidlet], i want to activate the UI. (another thread which downloads files from server will be still running, and on EDT thread i want to proceed with UI part)

    Which method is called when the midlet is maximized?

    Where i have to place the code for UI? (I checked startUp() is not called at this time, no canvas is shown before so i cannot use Canvas's showNotify())
    Shankar V N

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by shankar_vn View Post
    Hi all,
    Where i have to place the code for UI?

    (I checked startUp() is not called at this time, no canvas is shown before so i cannot use Canvas's showNotify())
    Hello,
    Why dont you put something as displayable at the time of the Maximization of the app.

    For example,
    Display.getDisplay(MUIDLET).setCurrent(someCanvas or someForm Object);
    As soon as you will write the above line the you can put the system.out.println() in the startApp and showNotify() and check where the controls moves.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    26

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by raj_J2ME View Post
    Why dont you put something as displayable at the time of the Maximization of the app.

    For example,
    Display.getDisplay(MUIDLET).setCurrent(someCanvas or someForm Object);
    Thanks for the reply, My question is the same, In which method i need to put
    Display.getDisplay(MUIDLET).setCurrent(someCanvas or someForm Object);
    so that the above code will be called when midlet is maximized
    Shankar V N

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by shankar_vn View Post
    Thanks for the reply, My question is the same, In which method i need to put
    Display.getDisplay(MUIDLET).setCurrent(someCanvas or someForm Object);
    so that the above code will be called when midlet is maximized
    Which device are you working with?
    are you working with the Canvas or the Form?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  5. #5
    Registered User
    Join Date
    Oct 2009
    Posts
    26

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Device: Nokia s60,s40 phones(not tested on s40), Sony ericsson JP 7,8 phones
    LWUIT form (assume it as normal LCDUI form)
    Shankar V N

  6. #6
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by shankar_vn View Post
    Device: Nokia s60,s40 phones(not tested on s40), Sony ericsson JP 7,8 phones
    LWUIT form (assume it as normal LCDUI form)
    background running application will not be supported by the S40 devices.
    For the rest of the device,

    Please note that you will be setting the application as running in the foreground on any of the particular events...correct?

    So at that time you will be setting the form as the displayable, so you try by putting the same in the constructor of the midlet.But this can vary from vendor to vendor.Please try this.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  7. #7
    Registered User
    Join Date
    Oct 2009
    Posts
    26

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by raj_J2ME View Post
    note that you will be setting the application as running in the foreground on any of the particular events...correct?
    Raj, Thanks again for your quick responses.

    As i told in my initial post, UI should be activated only when the user manually opens application(Application is already running without any ui) from Gallaery(Nokia) or Applications(SonyEricsson). Means there are no system/code events involved for UI activation.
    Shankar V N

  8. #8
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by shankar_vn View Post
    Raj, Thanks again for your quick responses.

    UI should be activated only when the user manually opens application(Application is already running without any ui) from Gallaery(Nokia) or Applications(SonyEricsson). Means there are no system/code events involved for UI activation.
    Hello,

    You have already idea that whether the app was started by the user manually or by the pushregistry..correct,
    Then you can try to put the code in the midlet's constructor in the condition like this.

    if(App started by user)
    {
    set displayable in the constructor of midlet.


    }
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  9. #9
    Registered User
    Join Date
    Oct 2009
    Posts
    26

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by raj_J2ME View Post
    You have already idea that whether the app was started by the user manually or by the pushregistry..correct,
    Yes, i know how check whether the app was started by the user manually or by the pushregistry.

    Quote Originally Posted by raj_J2ME View Post
    Then you can try to put the code in the midlet's constructor in the condition like this.
    if(App started by user)
    {
    set displayable in the constructor of midlet.
    }
    Interesting, are you saying that midlet's constructor will be called again when it is maximized?
    Let me give a quick try with System.out.println() in constructor.
    Shankar V N

  10. #10
    Registered User
    Join Date
    Oct 2009
    Posts
    26

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by raj_J2ME View Post
    Hello,

    Then you can try to put the code in the midlet's constructor in the condition like this.
    if(App started by user)
    {
    set displayable in the constructor of midlet.
    }
    I just tried with an alert in constructor, if the user manually opens the running app.
    But the constructor is not called at this time
    Shankar V N

  11. #11
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by shankar_vn View Post
    I just tried with an alert in constructor, if the user manually opens the running app.
    But the constructor is not called at this time
    Okay,
    Now try to put this in the startApp() method.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  12. #12
    Registered User
    Join Date
    Oct 2009
    Posts
    26

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by raj_J2ME View Post
    Okay,
    Now try to put this in the startApp() method.
    This was my initial trial without any success. startApp() is also not called at that movement.
    Shankar V N

  13. #13
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Are you doing this on Nokia's device?
    Now try in the showNotify().
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  14. #14
    Registered User
    Join Date
    Oct 2009
    Posts
    26

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Quote Originally Posted by raj_J2ME View Post
    Are you doing this on Nokia's device?
    Now try in the showNotify().
    I am testing this on Sony ericsson w705(JP 8.4 device with support for push registry)
    I haven't created any canvas object before maximizing the midlet, so how can i use showNotify()?
    Please have a look at my sample code

    Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    package com.mypackage;
    
    import java.io.IOException;
    import javax.microedition.io.HttpConnection;
    import javax.microedition.io.PushRegistry;
    import javax.microedition.lcdui.Alert;
    import javax.microedition.lcdui.AlertType;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    
    /**
     *
     * @author shankar.v
     */
    public class MyMidlet extends MIDlet implements CommandListener{
    
        public MyMidlet () {
            
        }
    
        protected void startApp() throws MIDletStateChangeException {
            showAlert("INSIDE startApp()!!!");
    		//CHECKING WHETHER THE APP IS STARTED AUTOMATICALLY OR MANUALLY
            if (isStartedAutomatically) {
                //Application autostarted
                startBackGroundThread();
            } else {
                //User started the application
                activateUI();
            }
        }
    
        protected void pauseApp() {
            
        }
    
        protected void destroyApp(boolean bln) throws MIDletStateChangeException {
            
        }
    
        private void startBackGroundThread(){
            // BackGroundThread logic comes here
        }
    
        private void activateUI(){
            showAlert("User started the application");
    		//code to show the initial form
        }
    
        public void showAlert(String message){
            Alert alert = new Alert("Hello", message, null, AlertType.INFO);
            alert.setTimeout(Alert.FOREVER);
            //alert.addCommand(new Command("OK", Command.OK, 1));
            alert.addCommand(Alert.DISMISS_COMMAND);
            //alert.setCommandListener(this);
            Display.getDisplay(this).setCurrent(alert);
        }
    
    }
    Shankar V N

  15. #15
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Which event is fired when the midlet is maximized [maximizing without minimizing]

    Make a class which extends the Canvas class.
    then you set this as the displayable,
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Graphics;

    public class HelloWorldCanvas extends Canvas {

    protected void paint(Graphics g) {

    g.setColor(0, 0, 0);
    g.fillRect(0, 0, getWidth(), getHeight());
    g.setColor(255, 255, 255);
    g.drawString("Hello World!", 20, 20, Graphics.LEFT | Graphics.BOTTOM);
    }
    }
    Put this in the same package and then create the object and set displayable.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. calling midlet from midlet throws SecurityException on 6600
    By brianpegan in forum Mobile Java General
    Replies: 3
    Last Post: 2010-10-25, 05:31
  2. Starting a MIDlet from another MIDlet
    By derdasser in forum Mobile Java General
    Replies: 4
    Last Post: 2009-02-25, 10:40
  3. 'Response Unknown' when downloading midlet
    By Weevil in forum Mobile Java General
    Replies: 3
    Last Post: 2004-05-30, 17:01
  4. How to create two instances of midlet
    By marquito99 in forum Mobile Java General
    Replies: 0
    Last Post: 2004-04-30, 01:33
  5. Idea about securing MIDlet
    By falconi in forum Mobile Java General
    Replies: 0
    Last Post: 2003-11-11, 00:36

Posting Permissions

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