Need Help in Changing Screen Orientation in Android

I want to change the screen orientation from portrait to landscape and vice versa when the user rotates his Android mobile phone clockwise/anticlockwise. Can anyone help me how to achieve this? I do not know what event is fired when the user rotates his Android mobile phone.

For instance, when the user touches the button in UI, touch event is fired. So, when the user shakes his Android mobile phone, what is the event that is fired? Please help me on this.

Answers


Hai, I got Solution with the help of Georgy Gobozov, But that solution has to be refined as shown below to work it properly,

@Override
    public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);

     if(newConfig.equals(Configuration.ORIENTATION_LANDSCAPE))
     {
         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);  
     }
     else if(newConfig.equals(Configuration.ORIENTATION_PORTRAIT))
     {
          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
     }
    } 

Need Your Help

How to escape Javascript code that is echoed in PHP

php javascript jquery ajax escaping

I have this code that is captured in the jquery Data object from a php page.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.