Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How control screen orientation of Android device

How I can control programmatically screen orientation of overall device and change it? Here links to some apps that can do that:

http://dandroidtabletpc.com/download-total-screen-control-1-9-3-full-android-apk.html/

http://ru.androidzoom.com/android_applications/tools/ultimate-rotation-control_bznhn.html

maybe somebody knows open source projects like this?

like image 422
user1348031 Avatar asked Dec 01 '22 22:12

user1348031


1 Answers

@Override
    public void onCreate(Bundle savedInstanceState) {
          setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
}

or

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
like image 92
clayton33 Avatar answered Dec 10 '22 11:12

clayton33