There is currently no way to disable rotation for the entire application. As a "global" solution you could extend all your Activities from a "Parent Activity" that has defined:
In the AndroidManifest.xml file inside the Activity block with the property screenOrientationyou can limit the rotation of the screen in your case it would be to put its value in portraitto block the view vertically, but you can join more values with the separator |, list of values:
I was reading that it is somewhat tedious to have to write this code in each activity and it is valid, this is a good alternative
just like this class "ClasePadre" extends from AppCompatActivity... you could extend your activities of ClassPadre so you would avoid so much code and make the changes according to your requirements Greetings = ) well here is the code
public class ClasePadre extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
super.onCreate(savedInstanceState);
}
Sorry but there is no way to make it global. The property " screenOrientation" must be used on each ' activity' ', at the level of ' application' ' there is nothing like it.
You can do it with the property
screenOrientation
inside yourAndroidManifest.xml
.Another option, which involves adding code for each activity, is:
It is added immediately after
onCreate()
:There is currently no way to disable rotation for the entire application. As a "global" solution you could extend all your Activities from a "Parent Activity" that has defined:
In the AndroidManifest.xml file inside the Activity block with the property
screenOrientation
you can limit the rotation of the screen in your case it would be to put its value inportrait
to block the view vertically, but you can join more values with the separator |, list of values:unspecified
behind
landscape
portrait
reverseLandscape
reversePortrait
sensorLandscape
sensorPortrait
userLandscape
userPortrait
sensor
fullSensor
nosensor
user
fullUser
locked
You can read more about them in the official Android documentation
I was reading that it is somewhat tedious to have to write this code in each activity and it is valid, this is a good alternative
just like this class "ClasePadre" extends from AppCompatActivity... you could extend your activities of ClassPadre so you would avoid so much code and make the changes according to your requirements Greetings = ) well here is the code
Sorry but there is no way to make it global. The property "
screenOrientation
" must be used on each 'activity
' ', at the level of 'application
' ' there is nothing like it.