Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 98
Registered: ‎01-06-2009
My Device: Pearl 8110

How to improve UI response w/ blocking process

Hi guys,

 

In my project I use bluetooth getFriendlyName(true) method, but this method

blocks UI events, so I cannot navigate the UI elements until the getFriendlyName(true)

returns. Can you suggest how I can make the UI responsive as 

scanning for friendly name occurs in the background? I already have this

scan in a background thread.

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to improve UI response w/ blocking process

If you have it in a background thread, then it should not be interfering with the UI events.

 

What is your UI event thread doing while the blutooth discovery is going on?

 

 

Highlighted
Developer
Posts: 24
Registered: ‎04-22-2009
My Device: Not Specified

Re: How to improve UI response w/ blocking process

I just wasted a few hours on this issue myself and thought I'd fill in the details of what is going on for anyone else who encounters this.

 

The inquiryCompleted() callback is always called on the event (UI) thread, even if you call startInquiry() from a background thread. You can verify this by having your code check the result of UiApplication.getUiApplication().isEventThread(). The API docs unfortunately leave out this key piece of information.

 

Since getFriendlyName() can open a connection to the device, it should not be called from inside of inquiryCompleted() because it will block the UI. Once you get the list of discovered devices, you can call getFriendlyName() on each one on another background thread.

 

-Tom B.