Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable landscape mode for a whole application

Is the there a way to set a landscape mode to the whole application, not by adding android:screenOrientation="portrait" to every activity in AndroidManifest?

like image 589
lomza Avatar asked Aug 22 '11 20:08

lomza


2 Answers

Here's the only thing I can think of. Write a class that extends Activity and put the following in that class:

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Then, instead of extending Activity in your other classes, extend the new class.

like image 106
SBerg413 Avatar answered Sep 19 '22 10:09

SBerg413


One programmatic way of doing this, that I can think of, is to create a super class that extends activity and extend all your classes from there.

Have the below setting in the super class in a protected method and call super.xxx() to initiate this:

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

In case you what a specific activity in a different way you can simply override this.

[I have not tried this yet, but by the knowledge of OOP this works]

like image 23
Kris Avatar answered Sep 18 '22 10:09

Kris