PopScreen() calling in onClose()?

Hi all

There are two ways to narrow screen, they are onClose() and popScreen()? The two of them go back to the previous screen battery, my question is: popScreen() call onClose() as well?

I found it. onUiEngineAttached() did the trick! I thank you all the same.

Tags: BlackBerry Developers

Similar Questions

  • How to close a popup screen pushed as a global screen

    I want to close a popup screen but my application is in background so

    UiApplication.getUiApplication () .popScreen (getScreen ());

    or

    UiApplication.getUiApplication () .getActiveScreen () m:System.NET.Sockets.Socket.close ();

    does not work is not something

    same Ui.getUiEngine () .getActiveScreen () m:System.NET.Sockets.Socket.close () does not work...

    in the popup screen, I have a custoListView (written own filed) there is an item when you click on an event

    listner function is called by there, I have to close popup screen... my class is like that

    SerializableAttribute public class SelectSms extends PopupScreen {}

    private vector _data;

    public boolean onClose() {}
    try {}
    Close();
    Returns true;
    } catch (Exception e) {}
    Returns false;
    }
    }

    public SelectSms() {}
    Super (new VerticalFieldManager(), Field.FIELD_VCENTER);
    _data = null;
    _data = MessageStore.getMessage ();
    last post [] message = Message [_data.size (new)];
    MSGC [] CustomListField = null;
    MSGC = new CustomListField [_data.size ()];
    for (int i = 0; i)<>
    message [i] = (Message) _data.elementAt (i);
    MSGC [i] = new CustomListField (message [i] .getMSG_BODY (), message [i] .getMSG_NO (), and [i] .getMSG_STUS ());
    last post mesg = message [i];
    MSGC [i] .setChangeListener (new FieldChangeListener() {}
    ' Public Sub fieldChanged (field field, int context) {}
    onClose();
    }
    });
    Add (MSGC [i]);
    }
    can someone help me how to close the popup screen.
            
    }
    }

    Place the UiApplication.popScreen () call in an executable object and pass this object to UiApplication.invokeLater ().

  • The value for a key in a PopupScreen "Cancel"

    Hello:

    I have a small problem to define a 'close' by default in a PopupScreen key. My PopupScreen has some EditFields, LabelFields and other things and I need when a press the button 'back' on the keyboard the PopupScreen person has to close.

    It's the "structure" of my class:

    public class ConfigureScreen extends PopupScreen
    {
        protected ButtonField _close;
    
        public Configure()
        {
            // Create and display ObjectChoiceField, EditField
            // the "_close" ButtonField and other things...
        }
    
        public void onClose()
        {
            // this is invoked by the _close ButtonField
            // and the "back" key
        }
    }
    

    As you can see I have a ButtonField 'close' which has FieldChangeListener set and call the onClose function that listens, I need that when the person press 'Return' ky, he should perform the onClose function.

    Sorry for my English and thanks for any help or reference you can give me.

    Peace.

    It's the complete solution:

    /**
     * Override the keyChar() method from PopupScreen.
     */
    protected boolean keyChar(char c, int status, int time)
    {
        switch(c) {
            case Characters.ESCAPE:
                onClose();
                break;
            default:
                return super.keyChar(c, status, time);
        }
    
        return true;
    }
    

    Thanks to YamilBracho for his help.

  • Close the Menu that appears

    I have a 'A' screen with a button that when you press shoot another screen 'B' in the stack. My problem is that when I click on the button control is not immediately transfer to screen 'B '. Instead, the menu of the display 'A', which has only a single element: "Close". This menu selection calls the onClose() method, which puts an end to the application.

    My first problem is that I do not understand why the menu of the display 'A' makes its appearance when I 'B' screen in the stack. I want to transfer control to the screen 'B' and do not see the menu [for the display 'A'] appears at all.

    Help someone?

    Thank you.

    You must add the CONSUME_CLICK style for your button.

  • IllegalArgumentException guard throw when calling popScreen()

    I added a MenuItem on a screen and I want to add a behavior of "previous screen".

    So I extended the class MenuItem of the substitution of the run() method. Table of contents including:

    UiApplication app = UiApplication.getUiApplication();app.invokeLater(new Runnable() {   public void run() {      UiApplication app = UiApplication.getUiApplication();      if (app.getScreenCount() > 1) {         Screen screen = app.getActiveScreen();     app.popScreen(screen);       }    }});
    

    I now get an IllegalArgumentException for a reason any.

    I called the following threads and tried different alternatives, but this exception is thrown again. I know it's because of the appeal to the pop method, but I can't seem to solve.

    "Screen problem.

    «Eception Exceptiion...» »

    «Re: switching screen...» »

    and recently

    IllegalArgumentException...

    Help, please!

    How will you do that, you can publish a piece of code here so that we can make changes to this topic... I suspect that you are in a bad way... Perhaps, the cause first of the IllegalArgumentException may be different... Reproduce this and post the snippet of code here...

    See you soon...

  • Replace the call button and hang up

    Hello

    To overrride the button back on a smart blackberry phone I override the onClose() method.

    Is there one or more similar methods for buttons (green) call and hangup (red)?

    I want to just make sure that whenever the user leaves the application exit code is executed.

    Thank you

    There are two options:

    1 to implement the keyListener (KeyListener) interface.

    2. replace deactivate() and close() functions.

  • Snap capture auto on incoming call event

    Hi all, write almost after 2 years.

    now I m developing an application regarding: "Application automatically captures a nod & send immediately by e-mail when it receives an incoming call..."

    I have done until now is: -.

    my code from the main class:

    public class ClickNSend extends UiApplication {
    
        /**
         * Entry point for application
         * @param args[0] = CALL_RECEIVED(Command line arguments)
         */
        public static void main(String[] args)
        {
            ApplicationPermissions permission = new ApplicationPermissions();
            permission.addPermission(ApplicationPermissions.PERMISSION_EMAIL);
            permission.addPermission(ApplicationPermissions.PERMISSION_MEDIA);
    
            if ( args.length > 0 && args[0].equals("CALL_RECEIVED")) {
                RegisterPhoneListener phone_handler = new RegisterPhoneListener();
                Phone.addPhoneListener(phone_handler);
                System.out.println("===================> started in auto-start up mode..");
            }
            else if ( args.length > 0 && args[0].equals("NORMAL_MODE")){
                System.out.println("===================> started in regular mode..");
                SnapShot app = new SnapShot();
                app.enterEventDispatcher();
            }
    
        }
    
        public ClickNSend(){}
    }
    

    (2) method phoneListener which is called code entering is given below

    private void checkCall(String ehandler, int callid){
            System.out.println("Status:::" + ehandler );
            callInfo = Phone.getCall(callid);
            UiApplication.getUiApplication().invokeLater(new Runnable()
            {
            public void run(){
                try {
                    AutoStartSnapShot app = new AutoStartSnapShot();
                } catch (Exception e) {
            System.out.println("Exception : "+e.getMessage());
            }
            }
            });
    }
    

    (3) class code AutoSartSnapShop

    public AutoStartSnapShot() {
            try{
                home = new MainScreen();
                p = Manager.createPlayer("capture://video");
                p.realize();
                System.out.println("----------->>> Player realized");
                p.prefetch();
                System.out.println("----------->>> Player prefetched");
                p.start();
                System.out.println("----------->>> Player started");
                vc = (VideoControl) p.getControl("VideoControl");
                viewFinder = (Field)vc.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
                home.add(viewFinder);
                //Thread.sleep(1500);
                pushScreen(home);
                new Thread() {
                    public void run() {
                        try {
                            capture();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }.start();
    
            } catch (Exception me){
                System.out.println(me.getMessage());
            } finally {
                popScreen(home);
            }
    
        }
    

    now my problem is that - when I received a call, an exception is thrown: application already running in this process... to "BOLD" statement / highlighted in above code...

    I stuck very bad... Please suggest a good solution

    It was solved by writing

    UiApplication.getUiApplication().pushGlobalScreen(new  AutoStartSnapShot(), 1, iEngine.GLOBAL_MODAL);
    

    insteade of Scripture

    UiApplication.getUiApplication().invokeLater(new Runnable() {
          public void run(){
              try {
                  AutoStartSnapShot app = new AutoStartSnapShot();
              } catch (Exception e) {
                  System.out.println("Exception : "+e.getMessage());
              }
          }
    });
    
  • onClose back button

    Hi friends

    I wanted to know if onClose() is called by default when we press return / escape button. It is a very strange problem to me that this was not a few days back. Although a while back I screwed up my code by application listener key because I wanted to close the screen when you press ESC. Now I removed KeyListener from my code, but its effect remains. I kept onClose because I want the user to get out that he presses a button.

    The framework calls onClose() in response to the ESC key if the screen has the DEFAULT_CLOSE style bit set. For the key ESC work, you must include DEFAULT_CLOSE whenever you explicitly set the style for your screen.

  • onExposed not called

    Hello

    I have a problem that a screen is not be changed because it's "onExposed" method is not called when I expect to be.

    Here's the scenario:

    1 screen 'foo' extends screen and is displayed.

    2. the user selects a menu item which, among other things, displays the 'bar' screen that extends PopupScreen.

    -'bar' screen in the event thread by using the following statement

    application.pushGlobalScreen (bar, 0, Dialog.GLOBAL_STATUS);

    3. the 'bar' screen gets popped display by a background with the following thread.

    synchronized (application.getAppEventLock ()) {}
    application.popScreen (bar);
    }

    4. after step 3 I was expecting the overloaded method 'onExposed' of the screen 'foo' to be called and refresh the data in the form. But this isn't the case.

    I tried a number of things, but I can't get the screen hidden to cool off when it is displayed.

    I run on the global phone OS4.2.1 Simulator.

    Any suggestions would be greatly appreciated.

    News Flash! The problem was in my code. onExposed has been called, but not when I thought it would be.

  • The synchronized application: creation of menu items for each call to makeMenu SQLite?

    A matter of design, which is a good implementation of the following?

    My requirements are:

    1. Have a different menu for each screen.
    2. The battery of the screen will be high both a single screen.
    3. To switch screens, the user must use the menu.

    I created the menu for each screen by the following:

    protected void makeMenu(Menu menu, int instance) {
    super.makeMenu(menu, instance);
    Database db = null;
    try {
    
      db = ResourceManager.getConnection(true);
      mCoffeeDao = new FlavshellDao();
      mTabDao = new FlavmDao();
    
      if (instance == Menu.INSTANCE_CONTEXT) {
          Bitmap logoWbg = Bitmap.getBitmapResource(resource
                  .getString(ScoreCenterResource.logo));
          Image image = ImageFactory.createImage(logoWbg);
    
          gMenu.setIcon(image);
          nMenu.setIcon(image);
          aMenu.setIcon(image);
          shMenu.setIcon(image);
          avMenu.setIcon(image);
          logoMenu.setIcon(image);
    
          menu.add(gMenu);
          menu.add(nMenu);
          menu.add(aMenu);
          menu.add(shMenu);
          menu.add(avMenu);
          menu.add(logoMenu);
      }
    
      if (instance == Menu.INSTANCE_DEFAULT) {
          menu.add(logMenu);
          menu.add(exitMenu);
    
          shell = mCoffeeDao.findAll();
    
          for (int i = 0; i < shell.length; i++) {
              Flavshell m = shell[i];
              /**
               * Ordering parameter, lower values are placed closer to the
               * top of the menu screen.
               */
              item = new FlavMenuItem(m.getPk(), m.getFlavortitle(),
                      200 + i);
              menu.add(item);
          }
    
          String[] params = {
              Integer.toString(this.mCoffeePk)
          };
          Flavm[] m = mTabDao.findByDynamicWhere("FLAVOR = ?",
                  params);
    
          if (m.length > 0) {
              for (int j = 0; j < m.length; j++) {
                  if (m[j] != null) {
                      Flavm specificMenu = m[j];
                      item = new FlavMenuItem(specificMenu.getPk(),
                              specificMenu.getTitle(), 100 + j);
                      menu.add(item);
                  }
              }
    
              menu.add(MenuItem.separator(105));
          }
      }
    
    } catch (FlavshellDaoException e) {
      Logger.logEventError(e.getMessage());
    
    } catch (FlavmDaoException e) {
      Logger.logEventError(e.getMessage());
    
    } finally {
      try {
          db.close();
      } catch (DatabaseException e) {
          Logger.logEventError("Menu Database error: " + e);
      }
    }
    

    I created a database with a single link object read in the following text:

    public synchronized static final Database getConnection(
        final boolean readOnly) {
    Database db = null;
    try {
        URI userFileURL = URI.create(System
                .getProperty("fileconn.dir.memorycard")
                + resource.getString(CoffeeHouseResource.db_path)
                + resource.getString(CoffeeHouseResource.db_name));
    
        db = DatabaseFactory.open(userFileURL, readOnly);
    
    } catch (MalformedURIException e) {
        Logger.logError("Get connection: URI: " + e.getMessage());
    } catch (ControlledAccessException e) {
        Logger.logError("Get connection: Controlled Access: "
                + e.getMessage());
    } catch (DatabasePathException e) {
        Logger.logError("Get connection: Database Path: "
                + e.getMessage());
    } catch (DatabaseIOException e) {
        Logger.logError("Get connection: Database IO: "
                + e.getMessage());
    } catch (Exception e) {
        Logger.logError(e.getMessage());
    }
    return db;
    }
    

    My question is,

    • If the user to call the menu as happening in any other activity database (SQLite), making the synchronized method will prevent database locks?
    • Should I design my makeMenu got a call from the database at all? It seems to me that all this works, this could potentially cause a lot of traffic on the SQLite database?
    • I thought to move the menu to a vector and storing the menu in storage Runtime, but I read that the Runtime Storage has the memory leak issues?

    Your basic design principles seem well - I have a number of applications that actually have "tabs" screens, so clicking on a tab or using the menu swaps from one screen to the other.  You can just push the new screen and pop, that. In fact, here's a menu from a screen, that I am currently working:

    _StatsMenu MenuItem = new MenuItem ("Stats", 110, 10) {}
    public void run() {}
    UiApplication.getUiApplication () .pushScreen (new StatsScreen (System.currentTimeMillis (), 0));
    UiApplication.getUiApplication () .popScreen (BaseScreenWithToolBar.this);
    }
    };

    While I haven't looked in detail, but your code dangerous look.

    I've never tested, but I suspect makeMenu is called using the EventThread.  Doing things like database connections in this method will cause you problems.  Do not.  If you need to query the database, do so before makeMenu is called.  Starts a separate Thread and set the appropriate menus if this Thread is not finished.  or block the user interface, until he made.

    In addition, I wouldn't do it in makeMenu:

    Bitmap logoWbg = Bitmap.getBitmapResource (resource
    .getString (ScoreCenterResource.logo));
    Image image = ImageFactory.createImage (logoWbg);

    You can do it once to the creation of the screen, or better yet, once at startup and save it in a shared domain.

    If you do not want to create a dynamic menu, then use the normal persistent store - or check out the details for the database once at startup and use them after that RAM.

    And avoid lifting heavy objects in makeMenu.

    I hope this helps.

  • The call coming and it's time to talk.

    I want to do something like.

    When the call comes and picked up then get her number of incoming call and it's time to talk.

    How can I achieve this.

    I work the first time on this type of application.

    Can someone tell me how can I do this with some piecs code.

    Coz it is very very urgent.

    Thank you

    Nitin

    See, PhoneLogListener is a listener that fires an event (which you choose) when this change occurs.

    In this case, we take calllogadded... so every time a new call log is added, it will run the code it contains.

    as regards the closing of the application goes... like I said earlier... I used an application of auto start as module system with no screen, no icon... that began with the start of the phone and still don't run in the background...

    But if you use screens in the application, it will be the icon... and then the second method (overrides the onClose method) can be used on the screen, when you exit the application.

    It will do this: when you close this screen where you will exit the application, the application will not be left but sent to bottom and appears in the application, just like any other background running application Ribbon... and will continue to do what he does... In our case get the logs of calls received.

    It could be that useful...

  • Run not called in thread

    I'm trying to get a thread that runs in the background to update a label field in a screen, but for some reason any of the thread run() method is not called. I'm using JDE 4.3.0.

    package UpdateTest;
    
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.MainScreen;
    import net.rim.device.api.ui.component.Dialog;
    import net.rim.device.api.system.DeviceInfo;
    import java.lang.Runnable;
    import java.lang.Thread;
    
    public class UpdateTest extends UiApplication
    {
        public UpdateTest()
        {
          pushScreen(new UpdateTestScreen());
        }
    
        public static void main(String[] args)
        {
            UpdateTest bm = new UpdateTest();
            bm.enterEventDispatcher();
        }
    } 
    
    final class UpdateTestScreen extends MainScreen
    {
        LabelField _field;
    
        UpdateThread upThread;
    
        public UpdateTestScreen()
        {
            super();
    
            upThread = new UpdateThread();
            upThread.start();
    
            setTitle("Update field test");
    
            add( new LabelField("field: ") );
            _field = new LabelField("0");
            add(_field);
        }
    
        public boolean onClose()
        {
            Dialog.alert("exit");
            upThread.stop();
            System.exit(0);
            return true;
        }
    
        public class UpdateThread extends Thread
        {
            private volatile boolean _start = false;
            private volatile boolean _stop = false;
            private static final int TIMEOUT = 500;
    
            public UpdateThread()
            {
                super();
                System.out.println("UpdateThread Created");
            }
    
            public void stop()
            {
                _stop = true;
                System.out.println("UpdateThread Stopped");
            }
    
            public void start()
            {
                _start = true;
                System.out.println("UpdateThread Started");
            }
    
            public void run()
            {
                System.out.println("UpdateThread running");
                for(;;)
                {
                    while( !_start && !_stop)
                    {
                        try {
                            sleep(TIMEOUT);
                            System.out.println("UpdateThread sleeping");
                        } catch (InterruptedException e) {
                            System.err.println(e.toString());
                        }
                    }
    
                    if (_stop)
                        return;
    
                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            _field.setText("" + System.currentTimeMillis());
                        }
                    });
                    System.out.println("invoked");
                }
            }
        }
    
    }
    

    If you go to substitute Thread.start, then call super.start () somewhere in there, like after your DD.

  • Function that is called in indesign is to terminate?

    Hello.

    I want to disconnect DB at the end of InDesign.

    This function exists in the InDesign SDK?

    For example, OnClose() or OnDestroy() of MFC.

    I guess that's the answer in a previous post. Please see the following link

    Function that is called in indesign is to terminate?

  • Window type "palette" and onClose event.

    Hi friends

    I m having a problem with an onClose event in a panel type "palette." Let´s try to explain the problem.

    Suppose I have this unique construction:

    var myDialog = new window ("palette", "My dialog box", undefined, {closeButton:false});})

    var bt = myDialog.add ('button', undefined, 'Ok', {name: 'ok'});

    myDialog.onClose = function() {}

    for example: app.activeDocument.layers.add ();

    };

    myDialog.show ();

    If I change the window to type 'dialogue', everything seems preety good, but if I keep the dialogue as a "palette" box, and then the 'Ok' button does not close the dialog and, of course, the onClose does not.

    PS: I need the onClose because event I want closing code executed even if the user press "ESC" rather than use the OK"" button.

    No idea how to handle or an alternative to make the button and onClose works?

    Thank you very much

    Best regards

    Gustavo.

    It does not work because the pallets and Illustrator don't communicate with each other, to call illustrator in a palette, you MUST use BridgeTalk, search on this forum, there are many examples.

  • New iPhone than 7 to 8 hours time to call to life

    I got a new iPhone 7 more, ordered through Verizon, a few days ago. Yesterday, I noticed that she had 8 hours and 51 minutes of life call time, which is impossible.

    This phone has replaced my iPhone 6

    I have not configured this phone via an iPhone backup 6. I plug it into iTunes once for synchronization of music and iTunes did ask if I want to set it up as a new phone. I said yes.

    I use the same iTunes/iCloud account that I used on my old phone, however.

    My use in line with Verizon for this month is only 113 minutes, so this number is clearly wrong.

    Still, I have the old phone and looked at the number of hours of calls from life. It's much more than 24 hours, the new phone has not inherit the old phone number.

    DIDS, I get a phone used or defective?

    Very strange... no one here can say what has happened. I go back to Verizon and ask them. If it was me, I insist on getting a new phone... that one has been used somewhere.

    Barry

Maybe you are looking for