If you want to disable Landscape mode for your android app ( or a single activity) all you need to do is add, android:screenOrientation="portrait" to the activity tag in AndroidManifest.xml file.
Example :
<activity android:name="YourActivityName"
android:icon="@drawable/icon"
android:label="Your App Name"
android:screenOrientation="portrait">
Now the activity YourActivityName be displayed only in portrait mode.
If you want to do this programatically ie. using Java code. You can do so by adding the below code in the Java class of the activity that you don't want to be displayed in landscape mode.
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
More Posts related to Android,
- Change Android Toast background color
- Maven : java.lang.ClassNotFoundException: Xmx512m
- This class should be public (android.support.v7.internal.widget.ActionBarView.HomeView) Lint Error
- Android Alert Dialog with Checkboxes example
- Android Error Generating Final Archive - Debug Certificate Expired
- How to add Newline to text in Android TextView
- Read Text file from SD Card : Android Programming
- [FIX] AndroidRuntime: FATAL EXCEPTION: main - java.lang.RuntimeException NullPointerException
- ActivityManager Warning: Activity not started, its current task has been brought to the front
- INSTALL_FAILED_INSUFFICIENT_STORAGE Android Error
- Android Developers Bluetooth Tutorial
- java.lang.ClassNotFoundException android.support.v7.widget.Toolbar [Fix]
- Android: Save Data in local Db using Android Room
- Channel 50 SMSes received every few minutes Android Phones
- 21 Useful Android Emulator Short-cut Keyboard Keys
- Changing Android Intent Tittle using java code
- Android : No Launcher activity found! Error
- How to change TextView or EditText Text Color on Focus and on Press
- How to display Toast on Button Click : Android
- Android : Execute some code after back button is pressed
- Stop android adb service from command prompt or terminal
- [Soluiton] You already have the latest version of Android Studio installed
- Create Custom Android AlertDialog
- Android R Cannot Be Resolved To A Variable
- How to make Android EditText not editable
More Posts:
- How to upgrade pip/pip3 package installer for Python - PIP
- How to Save Eclipse console logs in external log file - Eclipse
- zsh hello world example - Linux
- How to repeat background image in Android Activity - Android
- #HappyBirthdayJimin trending Happy Birthday Jimin BTS Army - BTS
- import servlet API to eclipse project (javax.servlet cannot be resolved error) - Java
- Disabling Spell Check in Android Studio - Android-Studio
- [Solved] Notepad++ Menu Bar Missing - NotepadPlusPlus