BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 09-13-2008, 06:03 AM   #1 (permalink)
Thumbs Must Hurt
Join Date: Oct 2007
Model: 7100i
Carrier: Dont know
Posts: 195
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default UI getting locked

Please Login to Remove!


in my application i first show a screen (this screen contains a loading Text in the paint method eg. Loading... like in gmail app) and a button. When i click the button i run a thread and retireves data from the server. Now to give UI responsive i run another thread which will keep on updating the Loading. text like this Loading. Loading.. Loading... , but the problem is the screen gets locked and in the screen the Loading is never updated as i wanted.

Iam confused since i am running the thread to update the text in the screen but the screen is still locked. Does anyone know what may be the problem.

Old 09-13-2008, 09:22 AM   #2 (permalink)
Thumbs Must Hurt
Join Date: Apr 2008
Model: 8130
Carrier: US Cellular
Posts: 82
Post Thanks: 0
Thanked 0 Times in 0 Posts

Instead of using a thread to refresh the UI, try a timer in your main thread. See Timer and TimerTask. Also, how are you waiting in your threads? Hopefully you're sleeping or waiting, and not just making busy loops.
Old 09-14-2008, 02:04 PM   #3 (permalink)
Thumbs Must Hurt
Join Date: Apr 2006
Location: Boston
Model: 8900
Carrier: AT&T
Posts: 98
Post Thanks: 0
Thanked 0 Times in 0 Posts


You may also want to keep in mind that the main-event thread is the only thread that's allowed to make modifications to UI stuff on the screen. A background thread - including a TimerTask - is not the main-event thread, so any changes you make to the UI will not appear at the execution of the statement, unless you put the code that will modify the UI into yet another thread, like the following:

UiApplication.getUiApplication().invokeLater( new Runnable()
    public void run()
        // modify the UI

Karl G. Kowalski
Owns a RAZR
Develops for BlackBerry
So next phone will iPhone 3G!

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.