0

I want to rotate my app when the landscape mode is activated, and to be fixed in Portrait mode(like a normal app). As I use a fragment manager, I decided to create an init method to programmatically decide to rotate or not my app instead of doing rotation for every fragments. here's the method:

public class ActivityHelper {
    public static void initialize(Activity activity) {
        int orientation = activity.getResources().getConfiguration().orientation;
        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }
}

The problem is that the app always stays in Portrait mode. Does someone have an idea? Thanks in advance

Ioan S.
  • 154
  • 3
  • 14

0 Answers0