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
Hithredin
Posts: 404
Registered: ‎06-03-2010
My Device: Z10 Red

Tilt event

[ Edited ]

Hello,

 

I am wondering about two possibilities between these ones:

 

1) Am I completly blind and cannot I read a Java reference?

 

2) Is it possible that RIM didn't even provided us an Event to handle tilt action, and advices us to use code tricks with the sublayout methods ?

 

 

 

Somebody has an answer?

Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Tilt event

i have not checked for 6.0.0, but as far as i am aware there is no event and you need to check it from sublayout to see if the Display.getWidth and height have switched. We just do this at the screen level and fire our own event.
Developer
mreed
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: Tilt event

i believe there is an accelerometer listener though. not sure how precise of a tilt you need to detect.
Developer
Hithredin
Posts: 404
Registered: ‎06-03-2010
My Device: Z10 Red

Re: Tilt event

Indeed, but the accelerometer listener always listen to the orientation, but here an alert from BB:

 

"Subscribing to accelerometer sensor readings is costly for the device battery, and should therefore only be used only when necessary."

 

 

 

The sublayout method may work but we need to register the last width in a private parameter. The pattern is not very sexy. Because:

 

-We need to reimplement this in all Screen in the extends hierarchy. If we change the lastWidth param for MyGenericScreen, the class MyImplementedScreen may not detect the tilt if we do not implement again the trick.

 

- We may want an action onTilt that has nothing to do with sublayout, but we still need to pass through it. so we need to get the event on every screen that can be push to stack to be certain to catch the event.