android - Opening activity in landscape mode without locking the orientation -


i want open activity in landscape orientation don't want lock orientation.that means user can switch orientation on rotating.i tried adding below code activity.it opens activity in landscape mode locked.

  setrequestedorientation(activityinfo.screen_orientation_landscape);    setrequestedorientation(activityinfo.screen_orientation_sensor); 

by adding android:configchanges="orientation|keyboardhidden" on activity , can handle when orientation change .

@override public void onconfigurationchanged(configuration newconfig) {    super.onconfigurationchanged(newconfig);    if (newconfig.orientation == configuration.orientation_portrait) {          //change orientation here     } else if (newconfig.orientation ==configuration.orientation_landscape{         //change orientation here    }  } 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -