I know there are two ways to set an Activity's orientation to landscape, either programmatically
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
or in the Manifest:
android:orientation="landscape"
Currently, I use the first one in a superclass, because I have many (child) activities that I all want to be always in landscape. However, this make
onCreate being called twice, which leads to other issues. When using the Manifest-route, I have to apply it to all activities separately, which will undoubtedly lead to one being missed out in the future (not to mention all the code copying).
Is there a way to apply android:orientation="landscape" to all activities in my app?
Or you can try make "superclass" for all activities and extends from "superclass".
public abstract class SuperActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With