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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -