before marking question duplicate, specify have strange requirement running through. app supported both phones , tablets, orientation supported tablets , not phones. have restricted work tablets. now, have strange issue, need enable orientation in 1 fragment in phone. in case xfragment within x module. how go without removing restriction on phones not supporting orientations. there other way around it? in fragment utils doing this:
public static void setactivityorientation(activity activity){ boolean tabletsize = myutils.istablet(activity); if (tabletsize) { activity.setrequestedorientation(activityinfo.screen_orientation_full_sensor); } else { activity.setrequestedorientation(activityinfo.screen_orientation_portrait); } } and calling oncreate @ base activity:
fragmentutils.setactivityorientation(this); how make work particular fragment? ideas? thanks!
if xfragment occupies whole screen, can use same code above in proper life cycle of xfragment as
public class xfragment extends android.support.v4.app.fragment{ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); if(!myutils.istablet(getactivity())){ getactivity().setrequestedorientation(activityinfo.screen_orientation_full_sensor); } } @override public void onpause() { super.onpause(); if(!myutils.istablet(getactivity())){ getactivity().setrequestedorientation(activityinfo.screen_orientation_portrait); } } } case 2:
if xfragment not in full screen , have multiple fragment, way call detach , attach xfragment manually.
Comments
Post a Comment