Avoiding IllegalStateException with inactive screens

I tried to avoid the IllegalStateExceptions... like a n00b I get them pretty often. I realized doing something on the screen the user jumped (bad, bad!) often gives an illegal state. I tried to write a method to detect if the screen is higher up in the stack, so I check first before doing anything on the screen, so if I do anything in a thread and have to come back later, I check if the screen is active, first.

{} public boolean isActive()
return UiApplication.getUiApplication () .getActiveScreen () is this;
}

I realized a few questions/issues with this approach.

  • If the user has the menu open... This code considers that the screen be IN-active, so my code won't do anything while the menu is open
  • I'd get an illegal state if I try to touch the screen below the menu when the user has a menu open? If Yes, this means I would have if sit and wait until the screen activates before I run the code after that I'll be back on the wire?
  • Would I be better to copy the invokeLater, runnables tail model, and then run then when screen is active? As in, the implementation of ScreenUiEngineAttachedListener and then try something like this below...

protected void invokeWhenActive (Runnable r) {}

store the executable

}

public void onScreenUiEngineAttached (attached screen, boolean) {}

{if (attached)}

check if we have pending runnables...

UiApplication.getUiApplication () .invokeLater (runnable);

}

}

What best practices can I keep in the spirit of updating the screens? To give a concrete example. Users select a category of points of interest (for example, police station, hospital) of a screen then I press the display of the result list that begins with the display of a loading animation. Then it will update when I get the info.

IllegalStateException may actually occur for various reasons.  But that being said, I'm not aware of any that are the result of a screen is not not the active screen.  So I suspect your presumption that it is the cause is not correct, I think that there is something else that goes along with the screen being burst that creates your problem.

I usually print the exception (. toString()) to know exactly why I got it.  You will find examples of this kind of thing

(a) you can get this by setting the focus on a field that is not actually on the screen - I think that the message will say something about "not apparent" or "not on the screen" (note that you can set the Focus on a field for a screen that is NOT on the top of the stack)

(b) adding a field to a Manager when the field is already added to a Manager, I think the message will say "already apparent.

So unless you print the detailed message, you will not be able to solve your problem.

Regard to deliver you from editing screen, don't forget not that when you update a screen, you must have the lock on the event - that's all just a lock that makes sure that only one thing is updating the user interface at the same time.  Now all the event handlers (menu key, etc.) running on the event Thread, which means that they all have the lock.  You can take advantage of that too.  You can plan a Runnable t run on the thread of events, when he has the lock on the event.  To do this, use this "incantation":

(UiApplication.getUiApplication), invokeLater (new Runnable() {}

public void run() {}

your UI code update

}

});

Thus, you should use this kind of process when you get the information you want.  Then push the ' loading screen, start your thread to download, have the wire download use this incantation to display the loading screen, and update the user interface.

Hope that answers the following questions:

See more here:

http://supportforums.BlackBerry.com/T5/Java-development/what-is-the-event-thread/Ta-p/446865

http://supportforums.BlackBerry.com/T5/Java-development/blocking-operation-not-permitted-on-event-di...

Tags: BlackBerry Developers

Similar Questions

  • Problem with matrix/screen in Qosmio F55-Q502

    Hello

    For a few weeks, I have a strange problem with matrix/screen of my laptop.
    The matrix flickers very often - no matter if the power cable is plugged in or not.
    The screen is full intensity and all of a sudden it starts flashing - it gets darker, lighter, usually for a few / dozen seconds. It does when no one touches or when I'm working on it.
    This very annoying and making eyes tired - he does it very fast and there is few levels of screen brightness.

    In addition, sometimes the screen turns off - you can see what is on the desktop but the screen is very very dark (but not empty or completely off). No reason - sometimes just in the workplace, sometimes for example when I touch (not pull) the power cable between the laptop and the power supply.
    Then, the only way to return to normal brightness of screen id to close the lid just for half a second and open it
    -matrix comes on normally, but can 'turns off' moment later and I have to do it once more - sometimes even several times...
    After 'action' with cover screens it seems that nothing ever happens...

    Anyone an idea what is the cause of such behavior or how to diagnose in details?
    Or maybe solve this problem?

    Best regards
    300 m

    Sounds like the backlight or inverter fails, or there is a bad connection.

    Is the unit under warranty? Send it to an ASP for repair.

    You should avoid to repair yourself, the backlight is very high voltage!

  • Go off & on several times before the monitor turns on. Comp seems to start OK but the problem is with the screen.

    Original title: XP start help please...

    ... are to be turned off & on several times before monitor lights. Comp seems to start OK but the problem is with the screen. Do I have to make a boot disk & if so - HOW?

    Hello

    ·         What is the brand and model of the computer?

    ·         You get the error message?

    ·         Did you check the connection of the cable to the monitor?

    ·         Have you tried to update to the latest graphics card and motherboard chipset drivers?

    First, try to connect your monitor to a well known PC, maybe the old laptop that you use now. If the monitor works, the problem is with the video card in your PC. If the monitor does not light, the monitor. It is usually cheaper to buy a new monitor that in order to be an old repaired, unless the monitor is still under warranty.

    Try connecting a monitor well known to your PC. If the monitor works, your old monitor is fried and needs to be replaced.

    If your monitor works when connected to another PC, the problem could be your video card. First, and then you turn on your PC, the power and cooling case fans run they. If they do not, it could be the power supply.

    Then, open the computer case. Before you do anything inside, unplug the power supply.

    IMPORTANT! Touch any metal part of the computer case to connect to the PC. A single static spark can destroy computer circuits.

    If the video card is the type of card that plugs into a slot on the motherboard, remove the screws or attached at the top of the card, remove the card, to manipulate the card by the edges to avoid disturbing the circuits on the card, carefully and re - install the card. Sometimes simply reinstalling the card corrects the problem.

    If this does not work, replace the video card with a card of similar type. Perhaps now is the right time for an update of video card.

    If the video card is integrated into the motherboard, you can install a new card in one of the PCI slots on the motherboard. When the PC starts for the first time, go into the bios and disable the onboard video.

    Resources for troubleshooting problems in Windows XP

    http://support.Microsoft.com/kb/307960

  • MacBook (2010) starts with black screen with flashing Apple logo

    I recently got ahold of a Macbook Pro 2010 running very slow so I did a reinstall of the operating system (which was a living nightmare, Macintosh is not as easy to manage as it was at the time of PowerPC) once I got to the top and running, I decided to upgrade to the latest version of El Capitan (an update (not an upgrade I already had a version out there) once I rebooted and let the computer do its thing he began to start up normally, but after finishing the progress bar, he went to a black screen (with the screen still on) that flashed the boot from time to time Apple logo. I forced shut down the computer and start in safe mode with success (that's how I'm typing this post now).

    Thanks in advance.

    When you reinstalled, did you remove any third-party system before reinstalling.

    A Mac that runs in Mode without failure, but are generally not normally indicates some incompatible system changes.

    Software common problems are things that are intended to clean, protect, optimize, accelerate, or otherwise maintain your Mac.

  • AMD Radeon 7570-devices is not compatible with Windows 10 - you're going to have problems with your screen

    Microsoft will come out with Windows 10, as an upgrade of the free operating system next month, July 29, 2015. They came out with an app, 'Get Windows 10', which is intended to help the operating system upgrade process. In this app, it checks for compatibility issues that may exist between your computer and their new Windows 10.  I get results for two of compatibility issues when I run this app. The one that concerns me, it is with the video card that came with my computer, AMD Radeon HD 7570.

    The app tells me: "these devices are not completely compatible with Windows 10" and he adds "you will encounter problems with your screen."

    Is there any driver updates that resolve this problem?

    The driver, I installed on my pc is Advanced Micro Devices, Inc. version 8.960.11.2000

    Windows says that the driver is up-to-date.

    If no driver is available to correct this problem will be I need to replace the video card in my computer and if so with what?

    I currently use two screens, a LG 22EA53 (analog) and an Acer S230HL without any problems with Windows 7, Home Premium, Service Pack 1.

    Malygris1,

    Well, son of a gun... looks that microsoft has made changes in their updates.

    Now when you run the "'get 10 app Windows, check your PC ' it reads in devices..." "0 problems found."

    Looks like Microsoft do with last-minute changes, as you indicated, and others have mentioned about being patient on this matter, that they may (?) have addressed this problem.  Probably won't suddenly course up until the update is done.

    Guess for now, I have to score this as accept as a Solution.

  • I downloaded 4 FF and now 5 and nor with my screen looks nothing like it says on the page of FF. For example, I don't have the orange FF tab in the upper left corner, I have no "PIN as app" option, nor do I view. Can someone help me please?

    I downloaded 4 FF and now 5 and nor with my screen looks nothing like it says on the page of FF. For example, I don't have the orange FF tab in the upper left corner, I have no "PIN as app" option, nor do I view. Can someone help me please?

    To get the orange FF tab, go to view > toolbars > menu bar. This should uncheck the menu bar giving you the orange button.

    Panorama is a box made of 4 gray rectangles which should be on the far right, if not once you activate the orange FF tab, right click anywhere on a toolbar that doesn't has nothing to this topic, and you should get a menu with a list of your toolbars that you can check and uncheck the box. Come on down to personalize everything down and it will open a window with all your buttons. Find groups of panorama/tab button and drag it to the toolbar of your choice.

    to pin a tab as an app, right-click on it; It is an option in the context menu.

  • Satellite Pro L20-someone ' one can tell me if I have a problem with the screen?

    Hello

    I have a Pro L20 - PSL25E and I recently had problems with the screen, it was intermittently flickering/lose color and whiting almost (when the color fades white vertical lines begin to appear).
    This seemed to worsen after that I dropped it (only from about 2 feet off the ground, not a big drop).

    I thought that the sceen can go, but the performance of the laptop seems to be affected when this happens, the laptop started to run very slow (tracks mouse slowly, programs I clicked take ages to run and it freezes sometimes to stop flashing) that had me thinking that it might be a virus or performance problem.

    My screen, drivers are updated, I did a full scan with McAfee, ran a clear-up system and a Defrag.

    I was wondering if anyone knew if it seemed to be a problem with the connections of the screen and would need replacement or if it could be repaired or if it were a performance problem?

    Any help would be great thank you appreciate!
    Rebecca.

    Looks like the graphics chip has a problem, which I think is a motherboard replacement.

    You can get a quote for repair to an authorized service provider. There is a list of ASP on the Toshiba site.

  • Portege M200 - pen does not work with the screen

    So I bought a pen for M200 and reinstalled the operating system.
    Now I M200 with Windows XP Tablet PC edition, a utility Screen Rotation and usefulness of the stylus button. Now Pen buttons work fine with my new pen, but the screen itself does not work. I mean, the stylus does not work with the screen.

    I have a mouse, and another menu pointing devices in Device Manager and it includes the following submenus:

    HID compatible mouse (I use the random DELL mouse)
    Mouse PS/2 Cimpatible (?)
    --------

    I think there must be something else...
    Please tell me, forum, what drivers should I download to get the pen to work?

    Stand by. Are you using the original image of recovery Toshiba (operating system) or you have installed your version?

  • Tecra S1 starts with blak screen

    Hello.

    I have a toshiba Tecra S1 1.6 ghz.
    I have a problem causing some time when I start the computer with white screen starts...
    The it started cause I hear the windows startup sound.
    I have try switching the Fn + F5, but nothink...

    Everything I do is to restart the computer to start with screen.

    Hello

    Hmm, how about display driver update?
    What do you think on the new operating system installation to check if this could solve the problem?

  • my photo does not work with the screen saver

    Photos has never worked on Apple TV 4 until today with the 032116 update, but my pictures does not work with the screen saver.

    I dare you to try to tell me how to make it work. Please have a solution, someone.

    Given that Apple isn't really care or help on these forums, it would be great if someone mentioned the steps.

    Thank you

    Can you elaborate on the question?

    These are user forums and this is why you will not see the participation of Apple here

  • My iPhone freeze with grey screen, then restart only. Subsequently, the Wifi is not available, I have to finish manually restart.

    My iPhone freeze with grey screen, then restart only. Subsequently the Wifi is not available, I have to finish manually restart to be able to use the Wifi. I have restart my internet and network settings, but the problem is still there.

    Hi there Turco911,

    Looks like your screen goes gray and then shuts down its own, and you must manually restart to get the wifi to work again. I save your device in iTunes, then restore it like new and verify that it works.

    How to clear your iOS device and then set up as a new device or restore from backups

    If this is the case, restore your backup either check it still works and just reinstalled software or circumvent the problem in the backup file itself.

    If when restored like new the problem persists, I would ask for your phone service:

    Repair - iPhone Apple Support

    Thank you for using communities of Apple Support, all the best!

  • 6 s iPhone restarts with black screen randomly. However, the system always restores the same question.

    I have an Iphone 6 s 128GB. The iphone automatically restarts with black screen and there is no particular application I use when it crashes.

    I did a system restore twice but still the same issue. Could someone please help?

    If the restore does not solve the problem, it is high time to take your device at the Apple Store for more diagnoostics. This may be material / display problem. Good luck.

  • Satellite L750 sometimes lit with white screen after hibernation

    When I got the system, sometimes awake hibenate with white screen!

    I noticed, when this happened, 'toshiba eco utility' is frozen.
    So, I think that: Toshiba Eco Utility is crushed, put into hibernation system and the awakening of the race, but screen blink.

    This time I push the power button, the system go to sleep and next push is normally awake!
    I don't know why. I use this app Eco Utility, but I'll delete it.

    Anyone?

    You deleted the Toshiba eco utility of the system now?
    Did you notice the same problem when you Hibernate your laptop using other profiles of power?

  • Problem with the screen on IPAD curtain

    Hello

    I'm a bad psychic, and I have a problem with the screen curtain.

    A longitudinal of Voice Over, the screen curtain is automatically activate.

    Normally to turn it off, you must type three times with three fingers. Only on my IPAD when I type three times with three fingers is "saying that turns off or preach. Find it me impossible to disable the screen curtain when voiceover is active.

    The latest version of IOS 9.2.1 is installed.

    I reset the Ipad and nothing changes.

    Can someone help me?

    Thank you

    Is is possible that the zoom is also on your iPad? If this is the case, try to use a quadruple 3 finger tap to turn off screen curtain.

    If the zoom is not active, try:

    1. Possessing the sleep/wake and home button until the Apple logo appears or 15-20 seconds.
    2. If, you can't remove the curtain of the screen, I would advise you reset the settings of the iPad. Settings > general > reset > reset all settings. It will be his turn VoiceOver off, but then you can use iTunes to turn on VoiceOver. Voice-over should return without the curtain of the screen automatically active. IOS - Apple Support using accessibility features

    The of is it possible that zoom is also active your iPad? In this case, you must use a valve 3 quadruple finger pour disable the screen curtain.

    try if the zoom is not enabled:
    1. While holding the button market / sleep and home to ' to the Apple logo, or 15-20 seconds.
    2. If you still can't delete the screen curtain, I recommend to RESET the settings on the iPad. Settings > General > RESET > RESET all settings. This turns off VoiceOver, but you can then use iTunes to turn on VoiceOver. Back to turn voiceOver should without the curtain automatically active screen. Use IOS - Apple support accessibility features

    -AJ

  • Satellite Pro U400-11V - Sharp noise when starting with connected screen

    Hello

    We received 5 x computers laptops Satellite Pro U400-11V, are excellent, with one exception:

    When you start (it happens on all of them) with a screen VGA monitor plugged in, a high beep is played from what looks like the speaker system. It occurs just before the first splash screen windows.

    Once the windows login screen is displayed a monitor can be connected to any problem & works very well.

    What can I check? I have had a look but do not find all the tracks so far, where this post.

    Thank you
    -A

    Perhaps you are meaning that the beep POST (Power on self test)?

    The laptop still sounds if the POST has been successfully passed.

    Parts of the motherboard will be verified during POST, and if everything is ok, a beep is displayed.

    If something would be a mistake, the laptop will not start and different beeps would appear.

    Welcome them

Maybe you are looking for