How to handle screen orientation in android ?

How to handle screen orientation in android ?



On 2014-06-10 03:18:38.0
Abakasha


Add this in Android Manifest file:
        android:configChanges="orientation"


On 2014-06-10 03:22:43.0
sonali
We can handle the screen orientation of our app in android Manifeast file . 
Ex : 
< activity 
            android:name="ActivityName"
            android:configChanges="orientation|keyboardHidden"
            android:label=""
            android:screenOrientation=["unspecified" | "behind" |
                                     "landscape" | "portrait" |
                                     "reverseLandscape" | "reversePortrait" |
                                     "sensorLandscape" | "sensorPortrait" |
                                     "userLandscape" | "userPortrait" |
                                     "sensor" | "fullSensor" | "nosensor" |
                                     "user" | "fullUser" | "locked"]  >  
    </activity>
 // this all are the options for handling the configuration change 
for more details [link text][1]


On 2014-06-10 03:27:48.0
Abakasha
http://developer.android.com/intl/es/guide/topics/manifest/activity-element.html


On 2014-06-10 03:28:49.0
Abakasha
We can handle the screen orientation by using  Orientation Pro-grammatically .
Example : 
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    switch (newConfig.orientation)
    {
    case Configuration.ORIENTATIONPORTRAIT:
        // taking action on event
        lockScreenRotation(Configuration.ORIENTATIONPORTRAIT);
    break;
    case Configuration.ORIENTATIONLANDSCAPE:
        // taking action on event
        lockScreenRotation(Configuration.ORIENTATIONLANDSCAPE);
    break;
    case Configuration.ORIENTATIONSQUARE:
        // taking action on event
        lockScreenRotation(Configuration.ORIENTATIONSQUARE);
    break;
    default:
        throw new Exception("Unexpected orientation!!!");
    break;
 }


On 2014-06-10 04:16:59.0
vinaykumar
Refer this Link it will definitely helps you.
http://techblogon.com/android-screen-orientation-change-rotation-example/


On 2014-06-10 06:41:59.0
sujata
@sujata .... Thank you .......:)


On 2014-06-10 08:14:27.0
Abakasha

copyright@questionsforum.net