-2

By the refrence to this link: Change Screen Orientation programmatically using a Button

is there any way to force the set orientation application forced to Automatic full (sensor_full) when ever i restart my device? :/ sorry as i am new here and i have problem with rotation, set orientation automatic full mode works with my tablet but i want it permanently, i have rooted my device and make the set orientation application as a system file, but whenever i reset my device i have to open set orientation and set it as automatic full manually. any help please?

Community
  • 1
  • 1

1 Answers1

0

Yes, you can set the screen orientation programatically anytime you want:

Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
final int orientation = display.getOrientation(); 
 // OR: orientation = getRequestedOrientation(); // inside an Activity

// set the screen orientation on button click
Button btn = (Button) findViewById(R.id.yourbutton);
btn.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {

              switch(orientation) {
                   case Configuration.ORIENTATION_PORTRAIT:
                       setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                       break;
                   case Configuration.ORIENTATION_LANDSCAPE:
                       setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                       break;                   
               }
          }
   });

also check this link,http://techblogon.com/android-screen-orientation-change-rotation-example/

Jignesh Jain
  • 1,518
  • 12
  • 28
  • dont mind, as i said i am new and dont know where to put these codes :D – Salik Iqbal Mar 30 '15 at 14:34
  • i already have a apk installed name https://play.google.com/store/apps/details?id=com.googlecode.eyesfree.setorientation&hl=en , after rooting the device, i have added this app as a system app, i also somehow know how to put a script which starts whenever my device will start, but excatly the thing i dont know what to write in script that open this apk when i start my device and set this app variable to set orientation full automatic(sensor_full), what to write below this line in script: #!/system/bin/sh – Salik Iqbal Mar 31 '15 at 09:18