-1

I am trying to develop an android application which requires me to open app a certain activity first in landscape mode however user must have that facility that they can change the orientation when they rotate the screen.

Issue is I can change to Landscape mode in onCreate however after that onConfigurationChanged() does not get called to make the orientation change to portrait or landscape as rotated by user.

Please let me know how should I handle it?

Saty
  • 2,563
  • 3
  • 37
  • 88

2 Answers2

1

For Land Scape

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

For portrait

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
kiran kumar
  • 1,402
  • 17
  • 34
  • Beginner bhai Saab wo mere ko pata hai...I did it to make the screen landscape. I want onConfiguration() get called like it does after calling setRequestedOrientation() which is not get called if you call setRequestedOrientation – Saty Jul 20 '15 at 05:52
  • Anyway I did a trick Timer mRestoreOrientation = new Timer(); mRestoreOrientation.schedule(new TimerTask() { @Override public void run() { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } }, 2000); – Saty Jul 20 '15 at 05:53
0

Set following property in the manifest file in the activity tag

android:configChanges="keyboardHidden|orientation"
Manish
  • 983
  • 1
  • 9
  • 27
  • No not working..I am testing it on device with android version 4.4.2 – Saty Jul 20 '15 at 05:10
  • Are you not getting call in the onConfigurationChanged method? Then provide more code from your activity and manifest file. – Manish Jul 20 '15 at 05:20