Orientation Changed event or Android listener

Is there any event or listener that changes orientation time?

or, how do you know if the phoneโ€™s orientation is changing?

thanks

+8
android android-orientation
source share
6 answers

You need to read Handling Runtime Changes .

He explains the old way of handling things like changing orientation.

Since Fragments was introduced, they introduced a new way to do this (similar to the old one), but if you are not using Fragments , it makes no sense to use it.

+4
source share

As far as I know, thereโ€™s a listener for this,

Check out http://developer.android.com/reference/android/view/OrientationListener.html

This is the class that is being viewed there.

Hope this helped.

+4
source share

Instead, you can use the OrientationEventListener class! http://developer.android.com/reference/android/view/OrientationEventListener.html

+2
source share

If you are more interested in when a change in orientation causes the layout to redisplay, you can check this: http://developer.android.com/reference/android/view/View.OnLayoutChangeListener.html

"Defining an interface for a callback that is invoked when layout boundaries change due to layout processing."

+1
source share

Since 180 ยฐ rotation is not determined by the onConfigurationChanged function,

See the best answer here: How to determine screen rotation

0
source share

On some change events, orentation fires before a real resize event. Do not recommend using the orientation change event when you need to know when the size of the form changes.

Just use $ (window) .resize (function () {stuff to do})

If you need to have dynamic resizing and resizing at some point, you can use this structure

 function ResizeEventHandler (){ var resizeEvent = function(){} this.ResizeEvent = function(value){ if (value!=null) resizeEvent = value; else return resizeEvent() } } var ResizeEventHandlerInstance = new ResizeEventHandler(); $(window).resize(function(){ ResizeEventHandlerInstance.ResizeEvent(); }); function YourDinamicalEventSetterFunction(){ ResizeEventHandlerInstance.ResizeEvent(function(){ alert('resized'); }); } 

basically, when you need to change the resize event -> change ResizeEventHandlerInstance ... and you will not need to turn off the event all the time when you want to change it.

-one
source share

All Articles