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 - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -