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: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Phone Vibrations do not occur when interacting with UI

Hey all, trying to make phone vibrate on a certain condition and it works fine, however, if I am currently interacting with the phone, typing, or changing apps or screens, the vibrations do not occur. If it is a three pulse vibration, then if after one pulse i stop using UI, then two pulses occur. I guess they both need eventThread and UI takes precedence? How could I get it to still vibrate even if using UI. If necessary I can make screen freeze while vibrating as the vibration is the most important but I know you can still vibrate and type when you get a text, etc.

 

My code for the vibrations is: 

 

if (repeat != false) {
					UiApplication.getUiApplication().invokeLater(
							new Runnable() {
								public void run() {
									for (int x = 0; x < savedList.size(); x++) {
										if (devicesListAddress
												.contains(savedListAddress
														.elementAt(x)) == false
												&& watchList
														.contains(savedListAddress
																.elementAt(x)) == false) {
											for (int b = 0; b < vibratelength; b++) {
												try {
													Alert.startVibrate(400);
													if (b != vibratelength)
														Thread.sleep(1000);
												} catch (InterruptedException e) {

												}
											}

 That is all that is relevant, it is not closed properly, that occurs later on. I use a new Runnable which is invokedLater, is this the proper way to trigger this event? Is there an alternative that could fix this? 

 

Thanks as always guys!

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Phone Vibrations do not occur when interacting with UI

format your code properly please.

do not use thread.sleep on the ui thread, it blocks it.
you can use a separate thread or a timertask.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter