TimerTask calling UiApplication.getEventLock)

I use a Timer object for several TimerTask objects that are run at various intervals (a few times per second, approximately every 30 seconds, etc, so nothing urgent). These objects TimerTask do very little work but they access various areas (e.g., setting the text of an EditField), and they call UiApplication.getEventLock () prior to do. And it works fine, no problem.

However, in order to ensure I'm good things, because TimerTask or objects of a Timer object to follow very quickly, calling UiApplication.getEventLock () would be a problem, as it can effectively block thread of the Timer object, which is supposed to "finish quickly." Thank you

The worst that will happen is that tasks planned for the future will be delayed in their execution. If your tasks are not urgent, then don't worry in this regard. In any case, nothing on the thread of the event is supposed to take long, either, so the wire from the timer should not have to wait a lot to synchronize the lock.

If this is a concern, you can always use invokeLater rather than synchronize the lock of the event.

Tags: BlackBerry Developers

Similar Questions

  • UiApplication.getEventLock () while alread in case of discussion?

    Hi people,

    I have a busy indicator, which is sometimes called from threads of the event and sometimes by background threads.

    Question: Although the extreme example below seems to work, does anyone know of an official RIM statement on the call of the lock of the event from somewhere that happens so that the event thread (as when a user presses a button)?

    Extreme example to get the lock event while in the wire of the event

    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
    public void run() {}
    {Synchronized (UiApplication.getEventLock ())}

    SOME WORK

    }

    }
    });

    Thank you

    I think that it is harmless to synchronize the lock of the event when already on the thread of the event. However, you can always check by using Application.isEventDispatchThread () (or Application.isEventThread (), if you have a ref for instance practice).

  • Becoming too much lag request

    Quick background: It is a scholarship application.

    Problem: the application has a component of the STOCK market . (one on the top part of the screen). Everything works perfectly in the Simulator, except the responsiveness of the application becomes too lag on a real device.

    What I do is, I have a separate socket connection wire that connects to our server and data are transmitted continuously. Whenever a new trade that happens in the stock market, the trade last is shown/updated on the screen of the user interface by using UiApplication.getEventLock (). When trades happen a few times, application to the interaction of the user response is perfect and smooth. But when pour trades (which means trades occur frequently and quickly), the responsiveness of applications becomes too lag to the point of simply irritate.

    My suspect is the high volume called UiApplication.getEventLock () that keeps the screen momentarily.

    Any suggestions for a work around?

    several approaches.

    first of all, you can try invokelater, he is not blocking your application, as does the synchronization on the eventlock.

    Second, more complicated:

    implement a queue, put your updates in here.

    "pump" your queue to the UI all few seconds (if there is a change) and view all new items at a time.

    If you use a listfield you can copy elements in the underlying vector, for example, and refresh it.

  • How can I restart a TimerTask, I want to reuse an instance of TimerTask on click of a button

    but I understand once you call it once that's all. That cannot be reused.

    I get everything I try and reuse the same instance of TimerTask errors of State invalid, surely there must be a way to restart?

    Hello

    public class TimersThread
    {
    Minu private;
    public TimersThread()
    {
    Timer = new Timer();
    Timer.Schedule (new TimerTask() {}
    public void run()
    {
    Synchronized (UiApplication.getEventLock ())
    {
    Timer.Cancel ();

    }
    }
    (}, 1000);
    }

  • navigationClick() called when you click outside a field.

    I have the following code below for the Blackberry Storm.  Its purpose is to make a menu screen with originally 4 BitmapFields that can be clicked.  All buttons work properly and regester and respond to the navigationClick() event.  However, if I click outside any field - the navigationClick() event is called on any field has the focus - even if the click is outside this area.

    Any help is appreciated

    SerializableAttribute public class MainMenu extends form {}

    Private MenuScreenLayoutManager menuScreen;
    protected MenuItem activate, soundOff, resume;
    protected UiApplication addix;
        
    public MainMenu (UiApplication addix) {}
    Super(MainScreen.FOCUSABLE |) MainScreen.NO_VERTICAL_SCROLL);
    This.addix = addix;
    LabelField title = new LabelField ("Addix", LabelField.HCENTER |) LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
    setTitle (title);
            
            
    getMainManager () .setBackground (BackgroundFactory.createBitmapBackground (Bitmap.getBitmapResource ("menu_background.png")));

    Set of MenuItem = new MenuItem (MenuItem.PLAY, Bitmap.getBitmapResource ("play_button.png"), Field.FOCUSABLE, this);
    Stats MenuItem = new MenuItem (MenuItem.STATS, Bitmap.getBitmapResource ("stats_button.png"), Field.FOCUSABLE, this);
    Help of MenuItem = new MenuItem (MenuItem.HELP, Bitmap.getBitmapResource ("help_button.png"), Field.FOCUSABLE, this);
    resume = new MenuItem (MenuItem.RESUME, Bitmap.getBitmapResource ("resume_button.png"), Field.FOCUSABLE, this);
    Activate = new MenuItem (MenuItem.SOUND_ON, Bitmap.getBitmapResource ("sound_on_button.png"), Field.FOCUSABLE, this);
    soundOff = new MenuItem (MenuItem.SOUND_OFF, Bitmap.getBitmapResource ("sound_off_button.png"), Field.FOCUSABLE, this);
            
    menuScreen = new MenuScreenLayoutManager();
    menuScreen.add (game);
    menuScreen.add (statistics);
    menuScreen.add (help);
    menuScreen.add (enable);
            
    Add (menuScreen);
    }
        
    private void addResume() {}
    menuScreen.add (curriculum vitae);
    }
        
    private void removeResume() {}
    menuScreen.delete (curriculum vitae);
    }
    }

    class MenuItem extends BitmapField {}
        
    public static final int PLAY = 0;
    public static final int SUMMARY = 1;
    public static final int STATS = 2;
    public static final int HELP = 3;
    public static final int SOUND_ON = 4;
    public static final int SOUND_OFF = 5;
    protected int type;
    private MainMenu mainMenu;

    public MenuItem (int, Bitmap bm, long style, MainMenu mainMenu type) {}
    Super (bm, style);
    This.type = type;
    this.mainMenu = mainMenu;
    }
        
    protected boolean navigationClick (int status, int time) {}
    System.out.println ("Type" + type);
    Field field;
    switch (type) {}
    case 0:
    System.out.println ("Play");
    synchronized (UiApplication.getEventLock ()) {}
    mainMenu.addix.pushScreen (new GameScreen (mainMenu.addix, mainMenu));
    }
    break;
    case 1:
    System.out.println ("Summary");
    break;
    case 2:
    System.out.println ("Stats");
    break;
    case 3:
    System.out.println ("help");
    break;
    case 4:
    System.out.println ("' sound - we '");
    () this.getManager replace (this, mainMenu.soundOff);
    break;
    case 5:
    System.out.println ("sound off");
    () this.getManager replace (this, mainMenu.soundOn);
                    
    break;
                
    }
    Returns true;
    }

    protected void (_g, Boolean _on Graphics) drawFocus {/ * nothing * /}
    }

    class MenuScreenLayoutManager extends VerticalFieldManager {}
        
    MenuItem field private;
    private static val mutable int menuItemsStartPos = 260;
    private static val mutable int menuItemHeight = 41;
    private static val mutable int menuItemWidth = 142;
    Private final int screenWidth = getWidth();
        
    public MenuScreenLayoutManager() {}
    Super(Manager.RIGHTMOST |) Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
    }
            
    protected void sublayout (int width, int height) {}
        
    int numberOfFields = getFieldCount();
    int menuXloc = 360-menuItemWidth;
    for (int i = 0; i)< numberoffields="" ;="" i++="">
    field = (i) getField (MenuItem);
    Switch (field.type) {}
                        
    case 0:
    setPositionChild (scope, menuXloc, menuItemsStartPos + (menuItemHeight + 3));
    layoutChild (field, width, height);
    break;
                            
    case 1:
    setPositionChild (scope, menuXloc, menuItemsStartPos);
    layoutChild (field, width, height);
    break;
                            
    case 2:
    setPositionChild (scope, menuXloc, menuItemsStartPos + 2 * (menuItemHeight + 3));
    layoutChild (field, width, height);
    break;
                            
    case 3:
    setPositionChild (scope, menuXloc, menuItemsStartPos + 3 * (menuItemHeight + 3));
    layoutChild (field, width, height);
    break;
                            
    case 4:
    case 5:
    setPositionChild (on the ground, 70, menuItemsStartPos + 3 * (menuItemHeight + 3));
    layoutChild (field, width, height);
        
    }
                        
    }
    setExtent (360, 460);
    }
    }

    It is one of the many design flaws (IMO) of the key on the blackberry event. What you get is by design.

    If you click anywhere on the screen where there is no field under the point of click, the click event will be dispatched on the ground right now with the update. You should override the touchEvent and write a 'isWithinBounds' method that checks just as the x and are coordinated are less than the width and the height of the field.

    The key event is within the limits of the field on which it is called, you handle if you ignore it.

  • How to call a second screen?

    I don't know exactly how to call a second display (displays the results of a web service) with some parameters.  I'm starting simple and sending the GPS coordinates of the current location.  I would like to call the service, and then view the name of the first result in the text field.  However, I get the infamous with is not the mistake of blocking event every time that I try to do the setText.  Can someone tell me what I'm doing wrong here?

    class Results extends UiApplication {    public static void main(String[] args) {        Results gbResults = new Results(args[1], args[2]);
    
            gbResults.enterEventDispatcher();    }
    
       private Results(String Latitude, String Longitude) {        pushScreen(new ResultsScreen(Latitude, Longitude));    }}
    
    final class ResultsScreen extends MainScreen{
    
        ResultsScreen(final String Latitude, final String Longitude) {        final LabelField lblResult = new LabelField("Result:", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);        add(lblResult);
    
            UiApplication.getApplication().invokeLater(new Runnable() {            public void run() {                //Call the service and get back [wsresult]                synchronized(UiApplication.getEventLock()) {                    lblResult.setText("Result: " + [wsresult]);                }            }        });    }}
    

    Now, I don't think that I need this class first results statement as in my first screen I call you just this screen like this:

    getUiEngine().pushScreen(new ResultsScreen(String.valueOf(qc.getLatitude()),String.valueOf(qc.getLongitude())));
    

    I think I'm calling and declaring the second screen correctly that the code is certainly get there.  There is just something to do with this setText.  What I need to do kind of the enterEventDispatcher () inside the ResultsScreen class?

    Also, I tried to do just the invokeLater by itself and the synchronize (getEventLock) by itself and kept getting the error each time.  It seems that no matter what I do, it always says that I'm not holding the lock on the event.

    I realized what the problem was.  When I called the getUIengine (.pushScreen), I was outside the event thread and so I had to wrap this call in a getAppLock as well.  When I was debugging before she looked like she came all the way to the setText (I'm sure that was the case somehow) and then wrong so I don't think that the appeal was the cause of the problem.

  • screen to push during the call

    Hello!

    I want to push a screen on top of everything I have on the device when I get an incoming/outgoing call or when I'm in a direct appeal... Now, what is happening here is that the phone freezes when I start the call from the phone book screen... If I press the call log screen, I have no problem at all. Here's how to add the screen. This is done in a thread separate, created and launched implementation of the method callInitiated (int callid)...

    synchronized (UiApplication.getEventLock())
    {
    UiApplication.getUiApplication().requestForeground();                       UiApplication.getUiApplication().pushScreen(new CustomScreen());
    }
    

    I'm trying different OS versions as for 8100 v 4.2.1.103 I'm not able to push any screen, while the application is in the background... (However, I put the application in the foreground before)...

    Best regards!

    Isabelle

    Please see the following link for an example on how to display a screen from a background application.

    How - to alert a user to a background application
    Article number: DB-00407

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

  • Access the user interface via TimerTask

    Hello

    I am trying to invalidate the screen for updating a clock of a TimerTask. Unfortunately, I keep getting errors that are probably related to the synchronization of the threads properly. Here is my code for the timer... it runs every 5000 milliseconds:

    public void runTimer()
        {
            TimerTask task = new TimerTask()
            {
                public void run()
                {
                    if (!_dragging && !_screenUnlocked)
                    {
                        UiApplication.getUiApplication().invokeLater(new Runnable()
                        {
                            public void run()
                            {
                                synchronized(UiApplication.getEventLock())
                                {
                                    UiApplication.getUiApplication().getActiveScreen().invalidate();
                                }
                            }
                        });
                    }
                }
            };
            _timer = new Timer();
            _timer.schedule(task, 0, _timerDelay);
        }
    

    Can someone help me understand how to correctly access the invalidate method? Moreover, this method is part of a subclass of full screen...

    You need not be on the wire of event to make the invalidate(), in fact, I would recommend that you aren't.

    There are two common ways to get on the thread of events:

    (1) UiApplication.getUiApplication (.invokeLater)

    (2) synchronized (UiApplication.getEventLock ())

    You must use one of the other, you do not need to use both.

  • How to push my application to the foreground after a phone call

    Hi all

    I develop a fairly simple application similar to a phonebook. It is possible to display the contact details and place a call to him with the help of a push button.

    I pass the call in this way:

        public void call(String number) {
    
            PhoneArguments phoneArgs = new PhoneArguments(PhoneArguments.ARG_CALL,
                    number);
            Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, phoneArgs);
    
        }
    

    It works very well, but at the end of the call of the interface of the telephone remains in the foreground. I can't understand how I can bring my application in the foreground.

    My application is supposed to work on different OS from 4.2.

    Thanks in advance for your help.

    Yes, but nothing too obvious.

    the phonelistener runs in the context of the phone application. If you call UiApplication.getUiApplication () you get a reference to the phone, not your own application.

    use a global event to connect the event to your application.

  • How to load images with a delay?

    Let's say I have a JSON from an HTTP request. The JSON contains several JPG and text links.

    For each JPG link and text, I want that they be displayed in a field like that.

    And here is the code in the field:

    public ProductField extends Field {
    
        String text;
        Bitmap bmp
    
        public CustomField(String text, String imageURL){
            bmp = Bitmap.getBitmapResource("blank.png");
        }
    
        public void paint(Graphics g){
            //....
        }
    
        public void updateBitmap(String url){
            bitmap = BitmapUtil.loadBitmapFromURL(url);
    
            // draw the bitmap on XYRect
            dest = new XYRect(0, 0, bitmap.getWidth(), bitmap.getHeight());
            invalidate();
        }
    }
    

    I realize that load images takes time, so I don't load them immediately. I have only to load the text and display an empty bitmap in the bitmap field. The actual bitmap will be charged when the updateBitmap() method is called.

    And here's how to add these field on the screen (not a 100% valid code, but I hope you will illustrate the idea)

    VerticalFieldManager vfm = new VerticalFieldManager
    
    // an array of bitmap URLS, which will be loaded later
    final String[] urls = new String[json_array_size];
    
    for (int x = 0; x < json_array.size; x++){
        CustomField field = new CustomField(..);
    
        // store bitmap URLs in array
        urls[x] = json_array.getJSONObject(x).getString("url");
        vfm.add(field);
        vfm.add(new SeparatorField());
    }
    
    Thread t = new Thread( new Runnable() {
        public void run() {
            for(int i = 0; i < len;i += 2) {
                synchronized(UiApplication.getEventLock()) {
                    CustomField cf = (CustomField) vfm.getField(i);
                    cf.updateBitmap(urls[i]);
               }
                try{
                    Thread.sleep(2000);
                }
                catch(Exception e){ }
                }
            }
    });
    

    Seems that all the images are loaded simultaneously. What I want is something like:

    display bitmap #1-2 seconds of delay - display bitmap #2 - delay 2 sec - display bitmap #3 - delay 2 sec etc..

    How to solve this problem?

    You can remove the block synchronized as you don't make any changes to the user interface, you read a value of a UI element.
    About your son, I can't get started, maybe a start() would help. do not race

  • Wire not invoked in a custom field?

    It is a field of 2048 blocks game, I made an animation effect to show a new block to his manager, but he did not.

    package com.walkline.util.ui;
    
    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.FontFamily;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.Ui;
    import net.rim.device.api.ui.UiApplication;
    
    import com.walkline.util.Function;
    
    public class BlockField extends Field
    {
        private static Font _font;
        private static final int CORNER_RADIUS = 12;
    
        private Object LOCK = new Object();
        private int _value = 0;
        private int _fore_color = 0;
        private int _background_color = 0;
        private String _text = "";
        private int _animation_size = 0;
    
        public BlockField()
        {
            super(NON_FOCUSABLE);
    
            try {
                int fontSize = 7;
                FontFamily family = FontFamily.forName("Tahoma");
    
                if (Display.getWidth() > Display.getHeight())
                {
                    if (Display.getWidth() > 480) {fontSize = 9;}
                } else {
                    if (Display.getHeight() >= 480) {fontSize = 9;}
                }
    
                _font = family.getFont(Font.EXTRA_BOLD, fontSize, Ui.UNITS_pt);
            } catch (ClassNotFoundException e) {}
        }
    
        public void clear() {setValue(0);}
    
        public int getValue() {return _value;}
    
        public void setValue(int value)
        {
            _value = value;
            _text = ((value != 0) ? String.valueOf(value) : ""); 
    
            _fore_color = ((_value > 4) ? 0xf9f6f2 : 0x776e65);
            setBackgroundColor();
        }
    
        public void setBackgroundColor()
        {
            switch (_value)
            {
                case 0:
                    _background_color = 0xccc0b3;
                    break;
                case 2:
                    _background_color = 0xeee4da;
                    break;
                case 4:
                    _background_color = 0xeee0c8;
                    break;
                case 8:
                    _background_color = 0xf2b179;
                    break;
                case 16:
                    _background_color = 0xf59563;
                    break;
                case 32:
                    _background_color = 0xf67c5f;
                    break;
                case 64:
                    _background_color = 0xf65e3b;
                    break;
                case 128:
                    _background_color = 0xffedcf72;
                    break;
                case 256:
                    _background_color = 0xffedcc61;
                    break;
                case 512:
                    _background_color = 0xffedc850;
                    break;
                case 1024:
                    _background_color = 0xffedc53f;
                    break;
                case 2048:
                    _background_color = 0xffedc22e;
                    break;
                case 4096:
                    _background_color = 0xff3c39;
                    break;
            }
        }
    
        public void startRun()
        {
            Thread thread = new Thread(new Runnable()
            {
                public void run()
                {
                    while (_animation_size < getWidth());
                    {
                        Function.errorDialog("size: " + _animation_size + ", width: " + getWidth());    
    
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {new Exception("thread exception: " + e.toString());}
    
                        _animation_size += 10;
                        if (_animation_size > getWidth()) {_animation_size = getWidth();}
    
                        invalidate();
                    }
                }
            });
            thread.start();
        }
    
        protected void layout(int width, int height)
        {
            _animation_size = width / 2;
            setExtent(width, height);
        }
    
        protected void paint(Graphics g)
        {
            g.setColor(_fore_color);
            g.setFont(_font);
            g.drawText(_text, (getWidth() - _font.getAdvance(_text)) / 2, (getHeight() - _font.getHeight()) / 2);
        }
    
        protected void paintBackground(Graphics g)
        {
            g.setColor(_background_color);
            g.fillRoundRect((getWidth() - _animation_size) / 2, (getHeight() - _animation_size) / 2, _animation_size, _animation_size, CORNER_RADIUS, CORNER_RADIUS);
        }
    }
    

    In the startRun() method, I changed the size of the painting and call invalidate(), but it is similar to code not working in the run() block, someone knows how to make it effective?

    Here's the correct code, FYI

    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.FontFamily;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.ui.Ui;
    import net.rim.device.api.ui.UiApplication;
    
    public class BlockField extends Field
    {
        private static Font _font;
        private static final int CORNER_RADIUS = 12;
    
        private int _value = 0;
        private int _fore_color = 0;
        private int _background_color = 0;
        private String _text = "";
        private int _animation_size = 0;
        private boolean _need_animation = false;
    
        public BlockField()
        {
            super(NON_FOCUSABLE);
    
            try {
                int fontSize = 7;
                FontFamily family = FontFamily.forName("Tahoma");
    
                if (Display.getWidth() > Display.getHeight())
                {
                    if (Display.getWidth() > 480) {fontSize = 9;}
                } else {
                    if (Display.getHeight() >= 480) {fontSize = 9;}
                }
    
                _font = family.getFont(Font.EXTRA_BOLD, fontSize, Ui.UNITS_pt);
            } catch (ClassNotFoundException e) {}
        }
    
        public void clear()
        {
            setValue(0);
            invalidate();
        }
    
        public void setAnimationMode(boolean value) {_need_animation = value;}
    
        public int getValue() {return _value;}
    
        public void setValue(int value)
        {
            _value = value;
            _text = ((_value != 0) ? String.valueOf(value) : "");
            _fore_color = ((_value > 4) ? 0xf9f6f2 : 0x776e65);
            _animation_size = getWidth() / 3;
    
            setBackgroundColor();
        }
    
        public void setBackgroundColor()
        {
            switch (_value)
            {
                case 0:
                    _background_color = 0xccc0b3;
                    break;
                case 2:
                    _background_color = 0xeee4da;
                    break;
                case 4:
                    _background_color = 0xeee0c8;
                    break;
                case 8:
                    _background_color = 0xf2b179;
                    break;
                case 16:
                    _background_color = 0xf59563;
                    break;
                case 32:
                    _background_color = 0xf67c5f;
                    break;
                case 64:
                    _background_color = 0xf65e3b;
                    break;
                case 128:
                    _background_color = 0xffedcf72;
                    break;
                case 256:
                    _background_color = 0xffedcc61;
                    break;
                case 512:
                    _background_color = 0xffedc850;
                    break;
                case 1024:
                    _background_color = 0xffedc53f;
                    break;
                case 2048:
                    _background_color = 0xffedc22e;
                    break;
                case 4096:
                    _background_color = 0xff3c39;
                    break;
            }
        }
    
        public synchronized void startAnimation()
        {
            new Thread()
            {
                public void run()
                {
                    while (_animation_size < getWidth())
                    {
                        try {
                            Thread.sleep(10);
    
                            _animation_size += 10;
                            if (_animation_size > getWidth()) {_animation_size = getWidth();}
    
                            synchronized (UiApplication.getEventLock()) {doPaint();}
                        } catch (InterruptedException e) {}
                    }
    
                    _need_animation = false;
                }
            }.start();
        }
    
        public synchronized void doPaint() {this.invalidate();}
    
        protected void layout(int width, int height) {setExtent(width, height);}
    
        protected void paint(Graphics g)
        {
            g.setColor(_fore_color);
            g.setFont(_font);
            g.drawText(_text, (getWidth() - _font.getAdvance(_text)) / 2, (getHeight() - _font.getHeight()) / 2);
        }
    
        protected void paintBackground(Graphics g)
        {
            g.setColor(_background_color);
    
            if (_need_animation)
            {
                g.fillRoundRect((getWidth() - _animation_size) / 2, (getHeight() - _animation_size) / 2, _animation_size, _animation_size, CORNER_RADIUS, CORNER_RADIUS);
            } else {
                g.fillRoundRect(0, 0, getWidth(), getHeight(), CORNER_RADIUS, CORNER_RADIUS);
            }
        }
    }
    
  • Dialog.ask () do not work?

    Hi all

    I called Dialog.ask (Dialog.D_YES_NO, "text") in class A that extern class Thread.

    I debuged and he ran on this line but the dialog box occur and my program is suspended.

    but Dialog.ask (Dialog.D_YES_NO, "text") work well when she called in the class screen extern class.

    No matter what suggesstion, thank you!

    I think that you must synchronize the lock of the event when calling Dialog.ask

    public class A extends Thread{
        public void run(){
            ...
            synchronized(UiApplication.getEventLock()){
                 Dialog.ask(...);
            }
            ...
        }
    
    }
    
  • BBM BasicMessageListManager disappears when I open the menu screen

    Hello

    I'm trying to integrate my application with the blackberry messaging platform. for this I use the SDK of BBM. I use a custom desktop to display messages. This screen contains a BasicReplyFieldManager defined as the State of the screen and a BasicMessageListManager that is added as a child of the live screen. This medication is ok, as long as I don't have to open the menu screen. By example, if I override the keyChar method to add messages to the BasicMessageListManager everything is ok. If, on the other hand, I use a menu option to do this, as soon as I open the menu, the BasicMessageListManager disappears. During debugging, I discovered that the BasicMessageListManagerof the Manager is set to null. That's why it disappears. The response of field does ' t disappear because it is in the State. If I put it in a BottomUpManager for example they both disappear.

    If someone has encountered this? or did someone knows how to get around this problem?

    Here is the code I use:

    replyField=new ReplyField();
    
    smilyBtn=new SmileyButton();
    smilyBtn.setClickRunnable(new Runnable() {
        public void run() {
            synchronized (UiApplication.getEventLock()) {
                SmileyScreen scr=new SmileyScreen();
                scr.show(replyField);
            }
        }
    });
    replyMgr=new BasicReplyFieldManager(replyField, smilyBtn);
    
    messageMgr=new BasicMessageListManager(0,
            MessageListManager.MESSAGE_STYLE_GROUP_MESSAGES_SAME_SENDER|
            MessageListManager.MESSAGE_STYLE_SHOW_SENDER_DISPLAY_NAME,
            MessageListManager.BORDER_STYLE_BUBBLE);
    messageMgr.toggle();
    BottomUpManager mgr=new BottomUpManager();
    mgr.add(messageMgr);
    mgr.add(replyMgr);
    add(mgr);
    

    to add messages, I use this

    MessageSender ms=new MessageSender("Me");
    TextMessage tm=new TextMessage(message, ms);
    OutgoingTextMessageField out=new OutgoingTextMessageField(tm);
    messageMgr.addMessage(out);
    

    Thank you.

    found the answear. It had nothing to do with the BBM SDK classes.

    I turns out I have outweigh the makeMenu method in the class of the screen and there I called menu.deleteAll. Once I removed this line everything was ok.

  • How to clear the text drafted the Bitmap by graphics.drawtext (...) (try to do a count down on top of the Bitmap)

    Hello, I'm doing a count down on top a Bitmap image. I use graphics.draw (),
    However, this ended up writing the text on text, no matter what I do.
    Example: when the second = 3, the image will be 3 shot
    When the second = 2, the image will be 2 on top 3 drawn on it (in this case 3 does not appear)
    When the second = 1, the image will be 1 of 2 on top 3 drawn on it (in which case 2.3 does not appear)

    Can anyone help please, thanks in advance... Here is the code:

    Timer each who calls every second {...
    {Synchronized (UiApplication.getEventLock ())}
    Bitmap temp = BitmapOriginal;
    Graphics g = Graphics.create (temp);

    Font myFont = Font.getDefault ().derive(Font.BOLD,13);

    StartcountDown.setFont (StartcountDown.getFont () .derive (Font.BOLD, 15, Ui.UNITS_pt));

    int xOffset = (int) ((BitmapOriginal.getWidth () / 2)-(Font.getDefault().getAdvance(Integer.toString(startCountDown))/2)); (temp.getWidth () - Font.getDefault () .getAdvance (Integer.toString (startCountDown)));
    int decalage_y = (int) ((BitmapOriginal.getHeight () / 2)-(Font.getDefault().getHeight()/2)); (temp.getHeight () - Font.getDefault () .getHeight ());

    g.setColor (Color.WHITE);
    g.setFont (myFont);

    g.Clear ();

    g.drawBitmap (0, 0, BitmapOriginal.getWidth (), BitmapOriginal.getHeight (), BitmapOriginal, 0, 0);
    g.drawText (Integer.toString (startCountDown), x_offset, decalage_y);

    PicAndText.setBitmap (temp);
    }
    ... }

    You can't disable text written on Bitmap. However, you don't have to write the text on the original. This:

    Bitmap temp = BitmapOriginal;

    won't. You copy not the original - you get a reference to it.

    Something like that

    Bitmap temp = new Bitmap(BitmapOriginal.getWidth(), BitmapOriginal.getHeight());
    Graphics g = Graphics.create(temp);
    g.drawBitmap(0, 0, temp.getWidth(), temp.getHeight(), BitmapOriginal, 0, 0);
    

    copies BitmapOriginal in temp, leaving intact and ready for the next use. The trick is to create a new bitmap every time to handle.

  • DELETE or blank Horizontal/Vertical/managers in a synchronous block

    Is it possible to empty the contents of a Manager after adding it to the screen.
    Example:
    My screen is composed of 3 parts. high/middle/low... I just want to change the content of the central part, without having to switch to any other page.
    I used to use the synchronous block and a TimerTask, update my screen... but this updates only found a content!
    If I had an image that I could update with a new image (not another object of different type)! However if I wanted to change the layout OF my Middle Manager, how can I do then?

    Thanks in advance...

    Code:
    ------------------
    Screen() {/ / / my screen Builder (extends screen)}

    Senior Manager

    ..

    middle Manager

    ..

    Fund Manager

    ..

    Add (Top);

    Add (Middle);

    Add (bottom);

    Functions.TT = New TimerTask() {}
    public void run() {}

    {Synchronized (UiApplication.getEventLock ())}

    my code that updates

    is there a way to dump the contents of the middle Manager and add new content?

    }

    }
    };
    t.scheduleAtFixedRate (Functions.tt, 100, 100);

    }
    ----------------------------------

    Thank you

    use mainManager.deleteAll () and add new fields to the mainManager. Try, it works for me.

    Thank you and best regards,

    Meera Manesh

Maybe you are looking for

  • MBP 12 'no battery available.

    I am owner of a retina of MBP 2012. This morning the battery was no longer recognized by the laptop and the battery in the top bar icon is an X. When I click it, it says "No available battery." When I click option, however, it says "State: Normal.» I

  • Re: Satellite A350 - PC Health Monitor or EcoUtility?

    Hello It is or will be like PC Health Monitor application or Toshiba Eco Utility for my laptop Toshiba Satellite A350-13? As an operating system I have Win7 64 bit. Thank you.

  • package installer error 1720 problem window

    Downloaded the Windows install 4.5 for my system tells me not the correct update.try to automatically update a tax programdownloaded update manually and still does not (installation)Get the error code 1720.problem with window installation package.rea

  • Restoration of ms office

    I can't open any office documents that system files have been removed with malice.  How can I recover?

  • PROBLEM LOADING WINDOWS 7 ON NEW HARD DRIVE

    Hi, I tried to load windows 7 on a new hard drive, I followed a guide online and all goes well until the final phase. The installation is blocked at the point of Windows is finalizing your settings there is a bar with a green light moving constantly