-2

How could I make such thing - when you rotate screen from horizontal to vertical application set on pasue (and show screen where is said that you should to rotate screen in vertical to continue e.t.c)?

Or how I can just disable screen rotation?

MarkMark
  • 157
  • 8

2 Answers2

2

Set the screen orientation to portrait or landscape (depending on your requirements) in the Android manifest file.

Then listen to the Accelerometer events if required.

See this question.

Community
  • 1
  • 1
Ranhiru Jude Cooray
  • 19,542
  • 20
  • 83
  • 128
1

I believe the answer you are looking for is in the activity life cycle of android apps.

I found this link and browsing it now. How do I disable orientation change on Android?

edit: from there I can see that all that needs to be done is modify

  1. android manifest file to include this in your activity

    <activity android:name="MainActivity" 
        android:configChanges="keyboardHidden|orientation|screenSize">
    
  2. inside your MainActivity this should be included

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
    
Community
  • 1
  • 1
Sybregunne
  • 179
  • 8