Question

I am using this CODE to disable the auto rotate in my App:

            android:screenOrientation="portrait"

What I want is to write a CODE inside my Activity to make the App on portrait or landscape as the user want by clicking a button and save it in SharedPreferences.

I am already made layout and layout-land with different design but as i disabled it in my Manifest its is not showing up, Cause i want the users chose what they want!

Thanks for any Help

UPDATE

    /** Here is the Rotation Button */
View.OnClickListener mb2 = new View.OnClickListener() {
    public void onClick(View v) {
        startActivity(new Intent(".ABOUT"));
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    }
};

It doesn't work this way!

Was it helpful?

Solution

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

or

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top