0

Is there any way to change Activity orientation from Fragment.

I am aware about following but it's not working.

activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_XYZ);

I put following as an Activity property and and it work.

android:configChanges="orientation|screenSize"

CLOSED

CoDe
  • 11,056
  • 14
  • 90
  • 197
  • I think it should be called before setContentView. I dont think you can do it from your fragment. – Emre Aktürk Sep 11 '14 at 10:52
  • I want to do it from fragment and I try to do it from onAttach ..any suggestion? – CoDe Sep 11 '14 at 10:53
  • call `getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);` from fragment – Michael Shrestha Sep 11 '14 at 10:58
  • @MichaelShrestha I tried same and it rotate as well and after display for a second it prompt error : "E/AndroidRuntime(25704): java.lang.IllegalStateException: Fragment BPConnectionFragment{4257e310} not attached to Activity " ..any suggestion ? – CoDe Sep 11 '14 at 11:00

0 Answers0